Add the same logic as for virt hosts to cloud spin up. When new instance is made it gathers the key automatically.

This commit is contained in:
Kevin Fenzi 2015-05-28 19:58:02 +00:00
parent b62619e9d3
commit e015807e72
2 changed files with 26 additions and 0 deletions

View file

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

View file

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