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 }}"
|
2020-08-28 09:28:53 +00:00
|
|
|
when: ansible_os_family in ["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}"
|
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:
|
2019-05-02 21:24:21 +00:00
|
|
|
dest: "{{ 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
|
|
|
|
follow: 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:
|
2019-05-02 21:24:21 +00:00
|
|
|
dest: "{{ 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
|
|
|
|
follow: 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
|
2020-08-28 09:28:53 +00:00
|
|
|
when: ansible_os_family in ["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
|
|
|
|
when: ansible_os_family in ["Flatcar Container Linux by Kinvolk"]
|