roles/networking: fix dns issues
This commit is contained in:
parent
3b1cfcf61a
commit
d6a1876fe8
@ -9,3 +9,6 @@ subnet_prefix: /24
|
|||||||
local_subnet: 192.168.0.0/24
|
local_subnet: 192.168.0.0/24
|
||||||
# router IP address
|
# router IP address
|
||||||
gateway: 192.168.0.1
|
gateway: 192.168.0.1
|
||||||
|
|
||||||
|
# Can be the server itself if it has a nameserver
|
||||||
|
nameserver: "{{ hostvars[groups['nameserver'][0]]['local_ip'] }}"
|
||||||
|
@ -38,9 +38,24 @@
|
|||||||
job: "/root/rmconn.sh"
|
job: "/root/rmconn.sh"
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
|
- name: Disable DHCP DNS
|
||||||
|
template:
|
||||||
|
src: nodns.network.j2
|
||||||
|
dest: /etc/systemd/network/50-nodns.network
|
||||||
|
|
||||||
|
- name: Create resolved configuration directory
|
||||||
|
file:
|
||||||
|
path: /etc/systemd/resolved.conf.d
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Set DNS
|
||||||
|
template:
|
||||||
|
src: dns_servers.conf.j2
|
||||||
|
dest: /etc/systemd/resolved.conf.d/50-dns_servers.conf
|
||||||
|
|
||||||
- name: Create NetworkManager connection
|
- name: Create NetworkManager connection
|
||||||
community.general.nmcli:
|
community.general.nmcli:
|
||||||
dns4: "{{ local_ip }}"
|
dns4: "{{ nameserver }}"
|
||||||
dns4_ignore_auto: yes
|
dns4_ignore_auto: yes
|
||||||
ip4: "{{ local_ip }}{{ subnet_prefix }}"
|
ip4: "{{ local_ip }}{{ subnet_prefix }}"
|
||||||
gw4: "{{ gateway }}"
|
gw4: "{{ gateway }}"
|
||||||
@ -57,7 +72,7 @@
|
|||||||
- name: Attempt to reconnect
|
- name: Attempt to reconnect
|
||||||
wait_for_connection:
|
wait_for_connection:
|
||||||
timeout: 240
|
timeout: 240
|
||||||
when: nmcli_conf.changed
|
when: nmcli_conf.changed or rmconn.changed
|
||||||
|
|
||||||
- name: Remove rmconn task at every minute
|
- name: Remove rmconn task at every minute
|
||||||
cron:
|
cron:
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
[Resolve]
|
||||||
|
DNS={{ nameserver }}
|
5
roles/networking/connection/templates/nodns.network.j2
Normal file
5
roles/networking/connection/templates/nodns.network.j2
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
[Match]
|
||||||
|
Name=*
|
||||||
|
|
||||||
|
[DHCP]
|
||||||
|
UseDNS=false
|
Loading…
Reference in New Issue
Block a user