commit 495ce63cdf08577c7f94f63caf232e97fdd0bf9c Author: Sven Velt Date: Tue Nov 27 14:32:06 2018 +0100 Initial commit diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..c5b50a2 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: Add name/IP to hosts file + lineinfile: + dest: /etc/hosts + regexp: '^{{ ansible_default_ipv4.address }}.*{{ ansible_hostname }}\.ansible\.kurs.*{{ ansible_hostname }}' + line: '{{ ansible_default_ipv4.address }} {{ ansible_hostname }}.ansible.kurs {{ ansible_hostname }}' + backup: yes + +- name: Clean/remove 127.0.1.1 + lineinfile: + dest: /etc/hosts + regexp: '127.0.1.1.*{{ ansible_hostname }}' + state: absent + backup: yes + +- name: Clean/remove 127.0.0.1 ... Hostname + lineinfile: + dest: /etc/hosts + regexp: '127.0.0.1.*{{ ansible_hostname }}' + state: absent + backup: yes + +- name: Ensure 127.0.0.1 localhost + lineinfile: + dest: /etc/hosts + regexp: '127.0.0.1.*localhost' + line: '127.0.0.1 localhost localhost.localdomain # from Ansible' + insertbefore: BOF + backup: yes +