2017-02-18 03:24:14 +08:00
|
|
|
# tasks file for ssh-key-rotation
|
|
|
|
- name: Generate a new ssh Key
|
|
|
|
command:
|
|
|
|
ssh-keygen
|
2023-11-07 21:39:17 +08:00
|
|
|
-t {{ ssh_key_algorithm }}
|
2017-02-18 03:24:14 +08:00
|
|
|
-N "{{ passphrase }}" -q
|
2023-11-07 21:39:17 +08:00
|
|
|
-f /home/{{ ssh_host_user }}/{{ ssh_key_path }}
|
2017-02-18 03:24:14 +08:00
|
|
|
-C {{ ssh_key_comment }}
|
|
|
|
when: inventory_hostname == play_hosts[0]
|
|
|
|
args:
|
2023-11-07 21:39:17 +08:00
|
|
|
creates: "/home/{{ ssh_host_user }}/{{ ssh_key_path }}"
|
2017-02-18 03:24:14 +08:00
|
|
|
delegate_to: localhost
|
|
|
|
|
|
|
|
- name: Store then value of the ssh key path
|
|
|
|
set_fact:
|
2023-11-07 21:39:17 +08:00
|
|
|
ssh_connection_key: "{{ lookup('file', '/' + 'home' + '/' + ssh_host_user + '/' + ssh_key_path + '.pub') }}"
|