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.

60 lines
1.7 KiB

  1. ---
  2. - name: create temporary resolveconf cloud init file
  3. command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
  4. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  5. - name: Remove search/domain/nameserver options
  6. lineinfile:
  7. dest: "{{item[0]}}"
  8. state: absent
  9. regexp: "^{{ item[1] }}.*$"
  10. backup: yes
  11. follow: yes
  12. with_nested:
  13. - "{{ [resolvconffile] + [base|default('')] + [head|default('')] }}"
  14. - [ 'search ', 'nameserver ', 'domain ', 'options ' ]
  15. notify: Preinstall | restart network
  16. - name: Add domain/search/nameservers to resolv.conf
  17. blockinfile:
  18. dest: "{{resolvconffile}}"
  19. block: |-
  20. {% for item in [domainentry] + [searchentries] + nameserverentries.split(',') -%}
  21. {{ item }}
  22. {% endfor %}
  23. state: present
  24. insertbefore: BOF
  25. create: yes
  26. backup: yes
  27. follow: yes
  28. marker: "# Ansible entries {mark}"
  29. notify: Preinstall | restart network
  30. - name: Add options to resolv.conf
  31. lineinfile:
  32. line: options {{ item }}
  33. dest: "{{resolvconffile}}"
  34. state: present
  35. regexp: "^options.*{{ item }}$"
  36. insertafter: EOF
  37. backup: yes
  38. follow: yes
  39. with_items:
  40. - ndots:{{ ndots }}
  41. - timeout:2
  42. - attempts:2
  43. notify: Preinstall | restart network
  44. - name: get temporary resolveconf cloud init file content
  45. command: cat {{ resolvconffile }}
  46. register: cloud_config
  47. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
  48. - name: persist resolvconf cloud init file
  49. template:
  50. dest: "{{resolveconf_cloud_init_conf}}"
  51. src: resolvconf.j2
  52. owner: root
  53. mode: 0644
  54. notify: Preinstall | update resolvconf for Container Linux by CoreOS
  55. when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]