main.yml 987 B

123456789101112131415161718192021222324252627
  1. - name: Hostname im Prompt setzen
  2. hostname:
  3. name: "{{inventory_hostname_short}}"
  4. - name: Hostname in /etc/hostname setzen
  5. copy:
  6. content: "{{inventory_hostname_short}}{{'\n'}}"
  7. dest: /etc/hostname
  8. owner: root
  9. group: root
  10. mode: 0644
  11. - name: Hostname für IPv4 in /etc/hosts setzen
  12. lineinfile:
  13. dest: /etc/hosts
  14. regexp: "^127.0.0.1"
  15. line: "127.0.0.1{{'\t'}}{{inventory_hostname}}{{'\t'}}{{inventory_hostname_short}}{{hostname_suffix}}{% if inventory_hostname != inventory_hostname_short %}{{'\t'}}{{inventory_hostname_short}}{% endif %}{{'\t'}}localhost"
  16. state: present
  17. - name: Hostname für IPv6 in /etc/hosts setzen
  18. lineinfile:
  19. dest: /etc/hosts
  20. regexp: "^::1"
  21. line: "::1{{'\t\t'}}{{inventory_hostname}}{{'\t'}}{{inventory_hostname_short}}{{hostname_suffix}}{% if inventory_hostname != inventory_hostname_short %}{{'\t'}}{{inventory_hostname_short}}{% endif %}{{'\t'}}localhost ip6-localhost ip6-loopback"
  22. state: present