diff --git a/tasks/main.yml b/tasks/main.yml index b8b827a..11fa311 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -28,6 +28,11 @@ file: path=/etc/network/interfaces.d state=directory when: ansible_os_family == "Debian" +- name: Create resolv.conf + template: src=resolv.conf.j2 dest=/etc/resolv.conf + with_items: "{{ dns_servers }}" + when: dns_servers is defined + - name: Create the network configuration file for ethernet devices template: src=ethernet_{{ ansible_os_family }}.j2 dest={{ net_path }}/ifcfg-{{ item.device }} with_items: network_ether_interfaces diff --git a/templates/resolv.conf.j2 b/templates/resolv.conf.j2 new file mode 100644 index 0000000..f4f83c7 --- /dev/null +++ b/templates/resolv.conf.j2 @@ -0,0 +1,15 @@ +# keep in mind to disable NetworkManager or else this will be overwritten, possibly disabling DNS + +{% if dns_servers is defined %} +{% for dns in dns_servers %} +nameserver {{ dns }} +{% endfor %} +{% endif %} + +{% if dns_search is defined %} +search {{ dns_search }} +{% endif %} + +{% if dns_domain is defined %} +domain {{ dns_domain }} +{% endif %}