When installing a new vm remove old and add new ssh host keys
This commit is contained in:
parent
05e35e953d
commit
06621bffff
1 changed files with 15 additions and 0 deletions
|
@ -37,6 +37,21 @@
|
||||||
delegate_to: "{{ vmhost }}"
|
delegate_to: "{{ vmhost }}"
|
||||||
when: inventory_hostname not in result.list_vms
|
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
|
- 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
|
local_action: wait_for delay=10 host={{ inventory_hostname }} port=22 state=started timeout=1200
|
||||||
when: inventory_hostname not in result.list_vms
|
when: inventory_hostname not in result.list_vms
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue