Sven Velt 6 lat temu
commit
495ce63cdf
1 zmienionych plików z 30 dodań i 0 usunięć
  1. 30 0
      tasks/main.yml

+ 30 - 0
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
+