0
0
ssh-key-rotation-role/tasks/generate_key.yaml

16 lines
547 B
YAML
Raw Permalink Normal View History

# tasks file for ssh-key-rotation
- name: Generate a new ssh Key
command:
ssh-keygen
-t {{ ssh_key_algorithm }}
-N "{{ passphrase }}" -q
-f /home/{{ ssh_host_user }}/{{ ssh_key_path }}
-C {{ ssh_key_comment }}
when: inventory_hostname == play_hosts[0]
args:
creates: "/home/{{ ssh_host_user }}/{{ ssh_key_path }}"
delegate_to: localhost
- name: Store then value of the ssh key path
set_fact:
ssh_connection_key: "{{ lookup('file', '/' + 'home' + '/' + ssh_host_user + '/' + ssh_key_path + '.pub') }}"