From 06621bffff0ef96387a66232dee0f9fe2ba9585d Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Wed, 22 Apr 2015 14:41:48 +0000 Subject: [PATCH] When installing a new vm remove old and add new ssh host keys --- tasks/virt_instance_create.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tasks/virt_instance_create.yml b/tasks/virt_instance_create.yml index 7565d2bb95..f0f20d7bb5 100644 --- a/tasks/virt_instance_create.yml +++ b/tasks/virt_instance_create.yml @@ -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