2016-09-23 01:14:51 +08:00
|
|
|
---
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Create temporary resolveconf cloud init file
|
2016-11-23 22:49:10 +08:00
|
|
|
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
|
2021-10-02 00:11:23 +08:00
|
|
|
when: ansible_os_family in ["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: |-
|
2022-02-27 02:29:23 +08:00
|
|
|
{% for item in [domainentry] + [searchentries] -%}
|
2016-11-30 21:06:11 +08:00
|
|
|
{{ item }}
|
2016-09-23 01:14:51 +08:00
|
|
|
{% endfor %}
|
2022-02-27 02:29:23 +08:00
|
|
|
{% for item in nameserverentries.split(',') %}
|
|
|
|
nameserver {{ item }}
|
|
|
|
{% endfor %}
|
2023-07-05 11:36:54 +08:00
|
|
|
options ndots:{{ ndots }} timeout:{{ dns_timeout | default('2') }} attempts:{{ dns_attempts | default('2') }}
|
2016-09-23 01:14:51 +08:00
|
|
|
state: present
|
2016-11-30 21:06:11 +08:00
|
|
|
insertbefore: BOF
|
2024-08-28 13:30:56 +08:00
|
|
|
create: true
|
2021-12-10 06:09:06 +08:00
|
|
|
backup: "{{ not resolvconf_stat.stat.islnk }}"
|
2016-11-30 21:06:11 +08:00
|
|
|
marker: "# Ansible entries {mark}"
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0644"
|
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:
|
2021-08-11 08:13:26 +08:00
|
|
|
path: "{{ item[0] }}"
|
2017-03-15 02:02:00 +08:00
|
|
|
regexp: '^{{ item[1] }}[^#]*(?=# Ansible entries BEGIN)'
|
2021-12-10 06:09:06 +08:00
|
|
|
backup: "{{ not resolvconf_stat.stat.islnk }}"
|
2017-03-15 02:02:00 +08:00
|
|
|
with_nested:
|
2023-07-05 11:36:54 +08:00
|
|
|
- "{{ [resolvconffile, base | default(''), head | default('')] | difference(['']) }}"
|
2022-09-24 01:42:27 +08:00
|
|
|
- [ 'search\s', 'nameserver\s', 'domain\s', 'options\s' ]
|
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:
|
2021-08-11 08:13:26 +08:00
|
|
|
path: "{{ item[0] }}"
|
2017-03-15 02:02:00 +08:00
|
|
|
regexp: '(# Ansible entries END\n(?:(?!^{{ item[1] }}).*\n)*)(?:^{{ item[1] }}.*\n?)+'
|
|
|
|
replace: '\1'
|
2021-12-10 06:09:06 +08:00
|
|
|
backup: "{{ not resolvconf_stat.stat.islnk }}"
|
2017-03-15 02:02:00 +08:00
|
|
|
with_nested:
|
2023-07-05 11:36:54 +08:00
|
|
|
- "{{ [resolvconffile, base | default(''), head | default('')] | difference(['']) }}"
|
2022-09-24 01:42:27 +08:00
|
|
|
- [ 'search\s', 'nameserver\s', 'domain\s', 'options\s' ]
|
2019-11-07 02:11:52 +08:00
|
|
|
notify: Preinstall | propagate resolvconf to k8s components
|
2017-03-15 02:02:00 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Get temporary resolveconf cloud init file content
|
2016-11-23 22:49:10 +08:00
|
|
|
command: cat {{ resolvconffile }}
|
|
|
|
register: cloud_config
|
2021-10-02 00:11:23 +08:00
|
|
|
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|
2016-11-23 22:49:10 +08:00
|
|
|
|
2023-07-26 22:36:22 +08:00
|
|
|
- name: Persist resolvconf cloud init file
|
2016-11-23 22:49:10 +08:00
|
|
|
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
|
2024-07-26 09:42:20 +08:00
|
|
|
mode: "0644"
|
2020-08-28 17:28:53 +08:00
|
|
|
notify: Preinstall | update resolvconf for Flatcar Container Linux by Kinvolk
|
2021-10-02 00:11:23 +08:00
|
|
|
when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
|