mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-05-23 00:37:42 -02:30
Update dir list
This commit is contained in:
60
roles/kubernetes/preinstall/tasks/0060-resolvconf.yml
Normal file
60
roles/kubernetes/preinstall/tasks/0060-resolvconf.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
---
|
||||
- name: create temporary resolveconf cloud init file
|
||||
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
|
||||
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
||||
|
||||
- name: Add domain/search/nameservers/options to resolv.conf
|
||||
blockinfile:
|
||||
dest: "{{resolvconffile}}"
|
||||
block: |-
|
||||
{% for item in [domainentry] + [searchentries] + nameserverentries.split(',') -%}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
options ndots:{{ ndots }}
|
||||
options timeout:2
|
||||
options attempts:2
|
||||
state: present
|
||||
insertbefore: BOF
|
||||
create: yes
|
||||
backup: yes
|
||||
follow: yes
|
||||
marker: "# Ansible entries {mark}"
|
||||
notify: Preinstall | restart network
|
||||
|
||||
- name: Remove search/domain/nameserver options before block
|
||||
replace:
|
||||
dest: "{{item[0]}}"
|
||||
regexp: '^{{ item[1] }}[^#]*(?=# Ansible entries BEGIN)'
|
||||
backup: yes
|
||||
follow: yes
|
||||
with_nested:
|
||||
- "{{ [resolvconffile, base|default(''), head|default('')] | difference(['']) }}"
|
||||
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
||||
notify: Preinstall | restart network
|
||||
|
||||
- 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('')] | difference(['']) }}"
|
||||
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
||||
notify: Preinstall | restart network
|
||||
|
||||
|
||||
- name: get temporary resolveconf cloud init file content
|
||||
command: cat {{ resolvconffile }}
|
||||
register: cloud_config
|
||||
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
||||
|
||||
- name: persist resolvconf cloud init file
|
||||
template:
|
||||
dest: "{{resolveconf_cloud_init_conf}}"
|
||||
src: resolvconf.j2
|
||||
owner: root
|
||||
mode: 0644
|
||||
notify: Preinstall | update resolvconf for Container Linux by CoreOS
|
||||
when: ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
|
||||
Reference in New Issue
Block a user