You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.2 KiB

  1. ---
  2. - name: Hosts | populate inventory into hosts file
  3. lineinfile:
  4. dest: /etc/hosts
  5. regexp: "^{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}$"
  6. line: "{{ hostvars[item]['ip'] | default(hostvars[item].ansible_default_ipv4.address) }} {{ item }}"
  7. state: present
  8. backup: yes
  9. when: hostvars[item].ansible_default_ipv4.address is defined
  10. with_items: groups['all']
  11. - name: Hosts | populate kubernetes loadbalancer address into hosts file
  12. lineinfile:
  13. dest: /etc/hosts
  14. regexp: ".*{{ apiserver_loadbalancer_domain_name }}$"
  15. line: "{{ loadbalancer_apiserver.address }} {{ apiserver_loadbalancer_domain_name| default('lb-apiserver.kubernetes.local') }}"
  16. state: present
  17. backup: yes
  18. when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
  19. - name: Hosts | localhost ipv4 in hosts file
  20. lineinfile:
  21. dest: /etc/hosts
  22. line: "127.0.0.1 localhost localhost.localdomain"
  23. regexp: '^127.0.0.1.*$'
  24. state: present
  25. backup: yes
  26. - name: Hosts | localhost ipv6 in hosts file
  27. lineinfile:
  28. dest: /etc/hosts
  29. line: "::1 localhost6 localhost6.localdomain"
  30. regexp: '^::1.*$'
  31. state: present
  32. backup: yes