michaelrigart / ansible-role-interfaces

An ansible role for configuring different network interfaces
GNU General Public License v3.0
83 stars 61 forks source link

dnsnameservers redhat? #41

Closed cavamagie closed 5 years ago

cavamagie commented 6 years ago

in the redhat the dnsnameservers is not enabled??

markgoddard commented 6 years ago

Could you provide some more information?

cavamagie commented 6 years ago

yes srry you can use this kind of info

roles:

and dnsnameservers: 192.0.2.1 192.0.2.2 work in debian with resolvconf but in redhat the value is not used in the configuration

grep -r dnsnameservers * README.md: dnsnameservers: 192.0.2.1 192.0.2.2 README.md: dnsnameservers: 192.0.2.1 192.0.2.2 README.md: dnsnameservers: 192.168.1.1 templates/ethernet_Debian.j2:{% if item.dnsnameservers is defined %} templates/ethernet_Debian.j2:dns-nameservers {{ item.dnsnameservers }}

markgoddard commented 6 years ago

Looks like you can set DNS1 and DNS2 in interface config files. Feel free to submit a PR.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s1-networkscripts-interfaces

cavamagie commented 6 years ago

ah ok we can add an

{% if item.dnsnameservers is defined %} DNS={{ item.dnsnameservers }} {% endif %}

to jnj file?

markgoddard commented 6 years ago

That might work for a single server, for two servers you would need to use DNS1 and DNS2. Try it out.

cavamagie commented 6 years ago

thanks @markgoddard

{% if item.dnsnameservers is defined %} {% if item.dnsnameservers.split(' ')[-2] is defined %} DNS2={{ item.dnsnameservers.split(' ')[-2]}} {% endif %} {% if item.dnsnameservers.split(' ')[-1] is defined %} DNS1={{ item.dnsnameservers.split(' ')[-1]}} {% endif %} {% else %} DNS1=xxxxx DNS2=xxxxx {% endif %}

markgoddard commented 6 years ago

How about:

{% if item.dnsnameservers is defined %} {% for dns_server in item.dnsnameservers.split(' ')[:2] %} DNS{{ loop.index + 1 }}={{ dns_server }} {% endfor %} {% endif %}

cavamagie commented 6 years ago

thank you!