diff --git a/tasks/persistent_cloud_new.yml b/tasks/persistent_cloud_new.yml index 3ffc457ea0..ab313357dc 100644 --- a/tasks/persistent_cloud_new.yml +++ b/tasks/persistent_cloud_new.yml @@ -44,6 +44,20 @@ local_action: wait_for host={{ public_ip }} port=22 delay=1 timeout=600 when: host_is_up|failed +- name: gather ssh host key from new instance + local_action: command ssh-keyscan -t rsa {{ inventory_hostname }} + ignore_errors: True + register: hostkey + when: host_is_up|failed + +- name: add new ssh host key (you still need to add it to official ssh_host_keys later) + local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ inventory_hostname }} state=present + ignore_errors: True + with_items: + - /root/.ssh/known_hosts + - /etc/ssh/ssh_known_hosts + when: host_is_up|failed + # SSH is up and running, however cloud-init still did not deployed ssh keypair # we have to wait some time. 10 sec is usually enough, but not always. - name: waiting for cloud-init diff --git a/tasks/transient_cloud.yml b/tasks/transient_cloud.yml index 69478a9b36..e432423a1a 100644 --- a/tasks/transient_cloud.yml +++ b/tasks/transient_cloud.yml @@ -36,6 +36,18 @@ - name: wait for he host to be hot local_action: wait_for host={{ nova_result.public_ip }} port=22 delay=1 timeout=600 +- name: gather ssh host key from new instance + local_action: command ssh-keyscan -t rsa {{ nova_result.public_ip }} + ignore_errors: True + register: hostkey + +- name: add new ssh host key (you still need to add it to official ssh_host_keys later) + local_action: known_hosts path={{item}} key="{{ hostkey.stdout }}" host={{ nova_result.public_ip }} state=present + ignore_errors: True + with_items: + - /root/.ssh/known_hosts + - /etc/ssh/ssh_known_hosts + # SSH is up and running, however cloud-init still did not deployed ssh keypair # we have to wait some time. 10 sec is usually enough, but not always. - name: waiting for cloud-init