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
|
changed_when: false
|
||||||
check_mode: no
|
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 }}
|
local_action: command ssh-keyscan -t rsa {{ inventory_hostname }}
|
||||||
ignore_errors: true
|
|
||||||
register: hostkey
|
register: hostkey
|
||||||
when: birthday is defined
|
when: birthday is defined
|
||||||
|
|
||||||
- name: add new ssh host key (until we can sign it)
|
- name: add new ssh host key (until we can sign it)
|
||||||
local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}"
|
local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}"
|
||||||
host={{ inventory_hostname }} state=present
|
host={{ inventory_hostname }} state=present
|
||||||
ignore_errors: true
|
|
||||||
with_items:
|
with_items:
|
||||||
- /root/.ssh/known_hosts
|
- /root/.ssh/known_hosts
|
||||||
when: birthday is defined
|
when: birthday is defined
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue