vm-install: Remove hosts from known hosts in the playbook
[noc.git] / ansible / remove_known_hosts.yml
diff --git a/ansible/remove_known_hosts.yml b/ansible/remove_known_hosts.yml
new file mode 100644 (file)
index 0000000..5491342
--- /dev/null
@@ -0,0 +1,11 @@
+- name: Purge host from known hosts
+  hosts: localhost
+  gather_facts: no
+  tasks:
+    - command: ssh-keygen -f ~/.ssh/known_hosts -R [{{ item }}]:{{ hostvars[vmname].ansible_port }}
+      with_items:
+        - "{{ hostvars[vmname].ansible_host }}"
+        - r3-{{ vmname }}
+        - r3g-{{ vmname }}
+        - r3e-{{ vmname }}
+        - "{{ hostvars[vmname].vm_network_cooked.primary.ip }}"