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