tasks/aws_cloud.yml: better known_hosts cleanup when birthday=yes
This commit is contained in:
parent
71847ba2f5
commit
5e8940375f
1 changed files with 9 additions and 3 deletions
|
@ -10,16 +10,22 @@
|
|||
changed_when: false
|
||||
check_mode: no
|
||||
|
||||
- name: gather ssh host key from new instance
|
||||
- name: birthday=on - drop the old known host entries
|
||||
local_action: known_hosts path={{item}}
|
||||
host={{ inventory_hostname }}
|
||||
state=absent
|
||||
with_items:
|
||||
- /root/.ssh/known_hosts
|
||||
when: birthday is defined
|
||||
|
||||
- name: gather the temporary ssh host key from the new instance
|
||||
local_action: command ssh-keyscan -t rsa {{ inventory_hostname }}
|
||||
ignore_errors: true
|
||||
register: hostkey
|
||||
when: birthday is defined
|
||||
|
||||
- name: add new ssh host key (until we can sign it)
|
||||
local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}"
|
||||
host={{ inventory_hostname }} state=present
|
||||
ignore_errors: true
|
||||
with_items:
|
||||
- /root/.ssh/known_hosts
|
||||
when: birthday is defined
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue