c12s-kubespray/roles/kubernetes/preinstall/tasks/resolvconf.yml
Bogdan Dobrelya da9da08964 Better fix for different CoreOS os family facts
Signed-off-by: Bogdan Dobrelya <bogdando@mail.ru>
2017-01-05 16:32:08 +01:00

64 lines
1.8 KiB
YAML

---
- 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: Remove search/domain/nameserver options
lineinfile:
dest: "{{item[0]}}"
state: absent
regexp: "^{{ item[1] }}.*$"
backup: yes
follow: yes
with_nested:
- "{{ [resolvconffile] + [base|default('')] + [head|default('')] }}"
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
notify: Preinstall | restart network
- name: Add domain/search/nameservers to resolv.conf
blockinfile:
dest: "{{resolvconffile}}"
block: |-
{% for item in [domainentry] + [searchentries] + nameserverentries.split(',') -%}
{{ item }}
{% endfor %}
state: present
insertbefore: BOF
create: yes
backup: yes
follow: yes
marker: "# Ansible entries {mark}"
notify: Preinstall | restart network
- name: Add options to resolv.conf
lineinfile:
line: options {{ item }}
dest: "{{resolvconffile}}"
state: present
regexp: "^options.*{{ item }}$"
insertafter: EOF
backup: yes
follow: yes
with_items:
- ndots:{{ ndots }}
- timeout:2
- attempts:2
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"]
- include: dhclient-hooks.yml
when: not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]
tags: [bootstrap-os, resolvconf]