mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-05-16 13:56:03 +08:00
When installing a new vm remove old and add new ssh host keys
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user