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.

36 lines
1.3 KiB

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