diff --git a/host_vars/test-playbook.yaml b/host_vars/test-playbook.yaml index eb55f9b..ffda72d 100644 --- a/host_vars/test-playbook.yaml +++ b/host_vars/test-playbook.yaml @@ -7,6 +7,12 @@ hosts: name: localhost - ip: 127.0.1.1 name: test-playbook.lab.dc.verdnatura.es test-playbook + +domain_name: verdnatura.es +search_name: verdnatura.es +resolvs: + - ip: 10.0.0.4 + - ip: 10.0.0.5 ################################################################################ ### FAIL2BAN #################################################################### diff --git a/roles/config-resolv/tasks/main.yaml b/roles/config-resolv/tasks/main.yaml new file mode 100644 index 0000000..090cc85 --- /dev/null +++ b/roles/config-resolv/tasks/main.yaml @@ -0,0 +1,10 @@ +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +- name: Replace old /etc/resolv.conf with new /etc/resolv.conf + template: + src: resolv.j2 + dest: "{{ path_resolv }}" + owner: root + group: root + mode: '0644' + backup: true +# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ diff --git a/roles/config-resolv/templates/resolv.j2 b/roles/config-resolv/templates/resolv.j2 new file mode 100644 index 0000000..8eb2aee --- /dev/null +++ b/roles/config-resolv/templates/resolv.j2 @@ -0,0 +1,7 @@ +domain {{ domain_name | default('verdnatura.es') }} +search {{ search_name | default('verdnatura.es') }} +{% if resolvs is defined %} +{% for resolv in resolvs %} +nameserver {{resolv.ip}} +{% endfor %} +{% endif %} \ No newline at end of file diff --git a/roles/config-resolv/vars/main.yaml b/roles/config-resolv/vars/main.yaml new file mode 100644 index 0000000..8e4edcf --- /dev/null +++ b/roles/config-resolv/vars/main.yaml @@ -0,0 +1,3 @@ +--- +# vars file +path_resolv: /etc/resolv.conf \ No newline at end of file