From afaf0e4a2c45bd947684816cdb912d48b0e87aa7 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Wed, 8 Jun 2016 09:47:02 +0000 Subject: [PATCH] Set resolv.conf on nodes before bootstrap In some clouds, the nodes created may not have a usable dns server from Neutron. Use the Google one, may set this role parameterized at some point. Change-Id: I05fcd867e47fcc45dab25d5be5c8349d272514f4 --- roles/set_resolv_conf/defaults/main.yml | 4 ++++ roles/set_resolv_conf/tasks/main.yml | 1 + roles/set_resolv_conf/templates/resolv.conf.j2 | 3 +++ set_resolv_conf.yml | 8 ++++++++ site.yml | 1 + 5 files changed, 17 insertions(+) create mode 100644 roles/set_resolv_conf/defaults/main.yml create mode 100644 roles/set_resolv_conf/tasks/main.yml create mode 100644 roles/set_resolv_conf/templates/resolv.conf.j2 create mode 100644 set_resolv_conf.yml diff --git a/roles/set_resolv_conf/defaults/main.yml b/roles/set_resolv_conf/defaults/main.yml new file mode 100644 index 0000000..ba257cc --- /dev/null +++ b/roles/set_resolv_conf/defaults/main.yml @@ -0,0 +1,4 @@ +--- +dns_nameservers: + - 8.8.8.8 + - 8.8.4.4 diff --git a/roles/set_resolv_conf/tasks/main.yml b/roles/set_resolv_conf/tasks/main.yml new file mode 100644 index 0000000..d9ebaec --- /dev/null +++ b/roles/set_resolv_conf/tasks/main.yml @@ -0,0 +1 @@ +- template: src=resolv.conf.j2 dest=/etc/resolv.conf diff --git a/roles/set_resolv_conf/templates/resolv.conf.j2 b/roles/set_resolv_conf/templates/resolv.conf.j2 new file mode 100644 index 0000000..0d5a0bb --- /dev/null +++ b/roles/set_resolv_conf/templates/resolv.conf.j2 @@ -0,0 +1,3 @@ +{% for s in dns_nameservers %} +nameserver {{ s }} +{% endfor %} diff --git a/set_resolv_conf.yml b/set_resolv_conf.yml new file mode 100644 index 0000000..fae391f --- /dev/null +++ b/set_resolv_conf.yml @@ -0,0 +1,8 @@ +--- +# file: set_resolv_conf.yml +- hosts: infra + gather_facts: no + user: ubuntu + become: true + roles: + - { role: set_resolv_conf } diff --git a/site.yml b/site.yml index 956144d..b4f7ca2 100644 --- a/site.yml +++ b/site.yml @@ -2,6 +2,7 @@ # file: site.yml - include: generate_infra_dynamic_groups.yml - include: wait_for_servers.yml +- include: set_resolv_conf.yml - include: common.yml - include: set_hostnames.yml - include: bootstrap_puppetmaster.yml