Created
April 8, 2017 06:26
-
-
Save glennswest/164d167df4fdb1d46c6f32be321bdedf to your computer and use it in GitHub Desktop.
Change RHEL 7 to use dnsmaq and /etc/host to do forward and reverse lookup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all:bastion | |
vars: | |
description: "Update /etc/hosts" | |
tasks: | |
- name: setup | |
setup: | |
- name: "Change PEERDNS=yes to PEERDNS=no" | |
replace: | |
dest: /etc/sysconfig/network-scripts/ifcfg-eth0 | |
regexp: '^PEERDNS=yes$' | |
replace: 'PEERDNS=no' | |
- name: "Fix ifcfg DNS Entry" | |
lineinfile: | |
dest: /etc/sysconfig/network-scripts/ifcfg-eth0 | |
line: 'DNS1=127.0.0.1' | |
state: present | |
- name: 'Copy and Backup the resolv.conf' | |
copy: | |
src: /etc/resolv.conf | |
dest: /etc/dnsmasq-resolv.conf | |
backup: yes | |
- name: 'dnsmasq to use new resolver' | |
replace: | |
dest: /etc/dnsmasq.conf | |
regexp: '^#resolv-file=$' | |
replace: 'resolv-file=/etc/dnsmasq-resolv.conf' | |
backup: yes | |
- name: 'restart dnsmasq' | |
service: | |
name: dnsmasq | |
state: restarted | |
- name: 'Remove resolv.conf' | |
file: | |
state: absent | |
path: /etc/resolv.conf | |
- name: 'Update resolv.conf' | |
blockinfile: | |
dest: /etc/resolv.conf | |
create: yes | |
block: | | |
nameserver 127.0.0.1 | |
search . | |
- name: 'restart network' | |
service: | |
name: network | |
state: restarted | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment