2016-09-23 01:14:51 +08:00
|
|
|
---
|
2016-11-23 22:49:10 +08:00
|
|
|
- name: create temporary resolveconf cloud init file
|
|
|
|
command: cp -f /etc/resolv.conf "{{ resolvconffile }}"
|
|
|
|
when: ansible_os_family == "CoreOS"
|
2016-09-23 01:14:51 +08:00
|
|
|
|
2016-11-30 21:06:11 +08:00
|
|
|
- name: Remove search/domain/nameserver options
|
2016-09-23 01:14:51 +08:00
|
|
|
lineinfile:
|
2016-11-30 21:06:11 +08:00
|
|
|
dest: "{{item[0]}}"
|
2016-09-23 01:14:51 +08:00
|
|
|
state: absent
|
2016-11-30 21:06:11 +08:00
|
|
|
regexp: "^{{ item[1] }}.*$"
|
2016-09-23 01:14:51 +08:00
|
|
|
backup: yes
|
|
|
|
follow: yes
|
2016-11-30 21:06:11 +08:00
|
|
|
with_nested:
|
|
|
|
- "{{ [resolvconffile] + [base|default('')] + [head|default('')] }}"
|
|
|
|
- [ 'search ', 'nameserver ', 'domain ', 'options ' ]
|
|
|
|
notify: Preinstall | restart network
|
2016-09-23 01:14:51 +08:00
|
|
|
|
2016-11-30 21:06:11 +08:00
|
|
|
- name: Add domain/search/nameservers to resolv.conf
|
2016-09-23 01:14:51 +08:00
|
|
|
blockinfile:
|
|
|
|
dest: "{{resolvconffile}}"
|
|
|
|
block: |-
|
2016-11-30 21:06:11 +08:00
|
|
|
{% for item in [domainentry] + [searchentries] + nameserverentries.split(',') -%}
|
|
|
|
{{ item }}
|
2016-09-23 01:14:51 +08:00
|
|
|
{% endfor %}
|
|
|
|
state: present
|
2016-11-30 21:06:11 +08:00
|
|
|
insertbefore: BOF
|
2016-09-23 01:14:51 +08:00
|
|
|
create: yes
|
|
|
|
backup: yes
|
|
|
|
follow: yes
|
2016-11-30 21:06:11 +08:00
|
|
|
marker: "# Ansible entries {mark}"
|
|
|
|
notify: Preinstall | restart network
|
2016-09-23 01:14:51 +08:00
|
|
|
|
|
|
|
- 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:
|
2016-09-27 17:54:12 +08:00
|
|
|
- ndots:{{ ndots }}
|
2016-09-23 01:14:51 +08:00
|
|
|
- timeout:2
|
|
|
|
- attempts:2
|
2016-12-07 23:57:05 +08:00
|
|
|
notify: Preinstall | restart network
|
2016-11-23 22:49:10 +08:00
|
|
|
|
|
|
|
- name: get temporary resolveconf cloud init file content
|
|
|
|
command: cat {{ resolvconffile }}
|
|
|
|
register: cloud_config
|
|
|
|
when: ansible_os_family == "CoreOS"
|
|
|
|
|
|
|
|
- name: persist resolvconf cloud init file
|
|
|
|
template:
|
|
|
|
dest: "{{resolveconf_cloud_init_conf}}"
|
|
|
|
src: resolvconf.j2
|
|
|
|
owner: root
|
|
|
|
mode: 0644
|
2016-12-07 23:57:05 +08:00
|
|
|
notify: Preinstall | update resolvconf for CoreOS
|
2016-11-23 22:49:10 +08:00
|
|
|
when: ansible_os_family == "CoreOS"
|
2016-11-30 21:06:11 +08:00
|
|
|
|
|
|
|
- include: dhclient-hooks.yml
|
|
|
|
when: ansible_os_family != "CoreOS"
|
|
|
|
tags: [bootstrap-os, resolvconf]
|