tasks/aws_cloud.yml: hack with known_hosts removal

We observed a situation when two keys were specified in known_hosts, and
only one was removed by the playbook.  At least we think this is what is
actually happening.
This commit is contained in:
Pavel Raiskup 2021-11-29 14:05:20 +01:00
parent 0270957497
commit 1efa0220c3

View file

@ -14,12 +14,16 @@
local_action: known_hosts path={{item}}
host={{ inventory_hostname }}
state=absent
# HACK! We repeat this task 3 times. We assume that "known_hosts" module is
# broken, and it removes only the first host key available (not all of them).
with_items:
- /root/.ssh/known_hosts
- /root/.ssh/known_hosts
- /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 ssh-ed25519 {{ inventory_hostname }}
local_action: command ssh-keyscan -t rsa {{ inventory_hostname }}
register: hostkey
when: birthday is defined