50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: DNS | Check if NetworkManager is being used
|
|
raw: systemctl status NetworkManager --no-pager
|
|
register: network_manager_in_use
|
|
ignore_errors: True
|
|
|
|
- name: DNS | Disable network NetworkManager management of resolv.conf
|
|
when: network_manager_in_use | succeeded
|
|
ini_file:
|
|
path: /etc/NetworkManager/NetworkManager.conf
|
|
section: main
|
|
option: dns
|
|
value: none
|
|
|
|
- name: DNS | load new resolv.conf
|
|
template:
|
|
unsafe_writes: yes
|
|
src: resolv.conf.j2
|
|
dest: /etc/resolv.conf
|
|
|
|
- name: DNS | Restarting NetworkManager
|
|
when: network_manager_in_use | succeeded
|
|
block:
|
|
- name: DNS | Restarting NetworkManager Service
|
|
systemd:
|
|
name: NetworkManager
|
|
state: restarted
|
|
daemon_reload: yes
|
|
enabled: yes
|
|
masked: no
|
|
- pause:
|
|
seconds: 5
|
|
- name: DNS | Waiting for connectivity to be restored to outside world
|
|
shell: if ! [[ $(ip -4 route list 0/0 | head -c1 | wc -c) -ne 0 ]]; then exit 1; fi
|
|
register: task_result
|
|
until: task_result.rc == 0
|
|
retries: 120
|
|
delay: 5
|