tasks/aws_cloud.yml: better known_hosts cleanup when birthday=yes

This commit is contained in:
Pavel Raiskup 2021-11-29 13:47:00 +01:00
parent 71847ba2f5
commit 5e8940375f

View file

@ -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