diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml new file mode 100644 index 0000000000000000000000000000000000000000..3316c1ad030b8edc40612bc099d02e76f556765d --- /dev/null +++ b/tasks/cleanup.yml @@ -0,0 +1,20 @@ +--- +# file: cleanup.yml + +- name: "Remove host from known_hosts" + known_hosts: + name="{{ item }}" + state="absent" + with_items: + - '{{ static_ipv4|default(False) }}' + - '{{ host }}' + +- name: "Remove host from hosts file" + lineinfile: + dest=/etc/hosts + regexp='{{ item }}' + state=absent + sudo: yes + with_items: + - '^{{ static_ipv4|default(False) }} ' + - '.*{{ host }}$' diff --git a/tasks/inithost.yml b/tasks/inithost.yml new file mode 100644 index 0000000000000000000000000000000000000000..7c6ddaca45a18cb11b2b2a7c5aa13af9348cc949 --- /dev/null +++ b/tasks/inithost.yml @@ -0,0 +1,4 @@ +--- +# file: inithost.yml + +- include: "cleanup.yml" diff --git a/tasks/main.yml b/tasks/main.yml index e17fa564d2cb5540557332990a5b0a54a7ca479a..947314d5738497499028b421847f47e5cc253048 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,3 +2,5 @@ # file: roles/cloud/tasks/main.yml - include: "{{ cloud|default('none') }}/{{ mode }}.yml" + +- include: "{{ mode }}.yml" diff --git a/tasks/removehost.yml b/tasks/removehost.yml new file mode 100644 index 0000000000000000000000000000000000000000..e0f71e6203fa00dcde0f68f9699d092ced0c3803 --- /dev/null +++ b/tasks/removehost.yml @@ -0,0 +1,5 @@ +--- +# file: removehost.yml + +- include: "cleanup.yml" + when: are_you_sure == "YES"