2016-09-22 17:14:51 +00:00
|
|
|
---
|
2016-11-23 14:49:10 +00:00
|
|
|
- name: create temporary resolveconf cloud init file
|
|
|
|
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
|
2017-01-05 15:32:08 +00:00
|
|
|
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
2016-09-22 17:14:51 +00:00
|
|
|
|
2017-03-14 18:02:00 +00:00
|
|
|
- name: Add domain/search/nameservers/options to resolv.conf
|
2016-09-22 17:14:51 +00:00
|
|
|
blockinfile:
|
|
|
|
dest: "{{resolvconffile}}"
|
|
|
|
block: |-
|
2016-11-30 13:06:11 +00:00
|
|
|
{% for item in [domainentry] + [searchentries] + nameserverentries.split(',') -%}
|
|
|
|
{{ item }}
|
2016-09-22 17:14:51 +00:00
|
|
|
{% endfor %}
|
2017-03-14 18:02:00 +00:00
|
|
|
options ndots:{{ ndots }}
|
|
|
|
options timeout:2
|
|
|
|
options attempts:2
|
2016-09-22 17:14:51 +00:00
|
|
|
state: present
|
2016-11-30 13:06:11 +00:00
|
|
|
insertbefore: BOF
|
2016-09-22 17:14:51 +00:00
|
|
|
create: yes
|
|
|
|
backup: yes
|
|
|
|
follow: yes
|
2016-11-30 13:06:11 +00:00
|
|
|
marker: "# Ansible entries {mark}"
|
|
|
|
notify: Preinstall | restart network
|
2016-09-22 17:14:51 +00:00
|
|
|
|
2017-03-14 18:02:00 +00:00
|
|
|
- name: Remove search/domain/nameserver options before block
|
|
|
|
replace:
|
|
|
|
dest: "{{item[0]}}"
|
|
|
|
regexp: '^{{ item[1] }}[^#]*(?=# Ansible entries BEGIN)'
|
2016-09-22 17:14:51 +00:00
|
|
|
backup: yes
|
|
|
|
follow: yes
|
2017-03-14 18:02:00 +00:00
|
|
|
with_nested:
|
|
|
|
- "{{ [resolvconffile] + [base|default('')] + [head|default('')] }}"
|
|
|
|
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
|
|
|
when: item[0] != ""
|
2016-12-07 15:57:05 +00:00
|
|
|
notify: Preinstall | restart network
|
2016-11-23 14:49:10 +00:00
|
|
|
|
2017-03-14 18:02:00 +00:00
|
|
|
- name: Remove search/domain/nameserver options after block
|
|
|
|
replace:
|
|
|
|
dest: "{{item[0]}}"
|
|
|
|
regexp: '(# Ansible entries END\n(?:(?!^{{ item[1] }}).*\n)*)(?:^{{ item[1] }}.*\n?)+'
|
|
|
|
replace: '\1'
|
|
|
|
backup: yes
|
|
|
|
follow: yes
|
|
|
|
with_nested:
|
|
|
|
- "{{ [resolvconffile] + [base|default('')] + [head|default('')] }}"
|
|
|
|
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
|
|
|
when: item[0] != ""
|
|
|
|
notify: Preinstall | restart network
|
|
|
|
|
|
|
|
|
2016-11-23 14:49:10 +00:00
|
|
|
- name: get temporary resolveconf cloud init file content
|
|
|
|
command: cat {{ resolvconffile }}
|
|
|
|
register: cloud_config
|
2017-01-05 15:32:08 +00:00
|
|
|
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
2016-11-23 14:49:10 +00:00
|
|
|
|
|
|
|
- name: persist resolvconf cloud init file
|
|
|
|
template:
|
|
|
|
dest: "{{resolveconf_cloud_init_conf}}"
|
|
|
|
src: resolvconf.j2
|
|
|
|
owner: root
|
|
|
|
mode: 0644
|
2017-01-05 10:35:16 +00:00
|
|
|
notify: Preinstall | update resolvconf for Container Linux by CoreOS
|
2017-01-05 15:32:08 +00:00
|
|
|
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|