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 }}"
|
2021-11-19 15:58:51 +00:00
|
|
|
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
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:
|
2019-05-02 21:24:21 +00:00
|
|
|
path: "{{ resolvconffile }}"
|
2016-09-22 17:14:51 +00:00
|
|
|
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
|
2016-11-30 13:06:11 +00:00
|
|
|
marker: "# Ansible entries {mark}"
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2019-11-06 18:11:52 +00:00
|
|
|
notify: Preinstall | propagate resolvconf to k8s components
|
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:
|
2021-08-11 00:13:26 +00:00
|
|
|
path: "{{ item[0] }}"
|
2017-03-14 18:02:00 +00:00
|
|
|
regexp: '^{{ item[1] }}[^#]*(?=# Ansible entries BEGIN)'
|
2016-09-22 17:14:51 +00:00
|
|
|
backup: yes
|
2017-03-14 18:02:00 +00:00
|
|
|
with_nested:
|
2017-03-16 14:58:17 +00:00
|
|
|
- "{{ [resolvconffile, base|default(''), head|default('')] | difference(['']) }}"
|
2017-03-14 18:02:00 +00:00
|
|
|
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
2019-11-06 18:11:52 +00:00
|
|
|
notify: Preinstall | propagate resolvconf to k8s components
|
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:
|
2021-08-11 00:13:26 +00:00
|
|
|
path: "{{ item[0] }}"
|
2017-03-14 18:02:00 +00:00
|
|
|
regexp: '(# Ansible entries END\n(?:(?!^{{ item[1] }}).*\n)*)(?:^{{ item[1] }}.*\n?)+'
|
|
|
|
replace: '\1'
|
|
|
|
backup: yes
|
|
|
|
with_nested:
|
2017-03-16 14:58:17 +00:00
|
|
|
- "{{ [resolvconffile, base|default(''), head|default('')] | difference(['']) }}"
|
2017-03-14 18:02:00 +00:00
|
|
|
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
2019-11-06 18:11:52 +00:00
|
|
|
notify: Preinstall | propagate resolvconf to k8s components
|
2017-03-14 18:02:00 +00:00
|
|
|
|
|
|
|
|
2016-11-23 14:49:10 +00:00
|
|
|
- name: get temporary resolveconf cloud init file content
|
|
|
|
command: cat {{ resolvconffile }}
|
|
|
|
register: cloud_config
|
2021-11-19 15:58:51 +00:00
|
|
|
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
2016-11-23 14:49:10 +00:00
|
|
|
|
|
|
|
- name: persist resolvconf cloud init file
|
|
|
|
template:
|
2019-05-02 21:24:21 +00:00
|
|
|
dest: "{{ resolveconf_cloud_init_conf }}"
|
2016-11-23 14:49:10 +00:00
|
|
|
src: resolvconf.j2
|
|
|
|
owner: root
|
|
|
|
mode: 0644
|
2020-08-28 09:28:53 +00:00
|
|
|
notify: Preinstall | update resolvconf for Flatcar Container Linux by Kinvolk
|
2021-11-19 15:58:51 +00:00
|
|
|
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|