When installing a new vm remove old and add new ssh host keys

This commit is contained in:
Kevin Fenzi 2015-04-22 14:41:48 +00:00
parent 05e35e953d
commit 06621bffff

View file

@ -37,6 +37,21 @@
delegate_to: "{{ vmhost }}"
when: inventory_hostname not in result.list_vms
- name: make sure there is no old ssh host key for the host still around
local_action: known_hosts path={{item}} host={{ inventory_hostname }} state=absent
ignore_errors: True
with_items:
- /root/.ssh/known_hosts
- /etc/ssh/ssh_known_hosts
when: inventory_hostname not in result.list_vms
- name: Add new ssh_host_key for newly installed host
local_action: known_hosts path={{item}} host={{ inventory_hostname }} state=present
ignore_errors: True
with_items:
- /root/.ssh/known_hosts
when: inventory_hostname not in result.list_vms
- name: wait for ssh on the vm to start back
local_action: wait_for delay=10 host={{ inventory_hostname }} port=22 state=started timeout=1200
when: inventory_hostname not in result.list_vms