summaryrefslogtreecommitdiffstats
path: root/roles/openshift_node_dnsmasq
diff options
context:
space:
mode:
Diffstat (limited to 'roles/openshift_node_dnsmasq')
-rwxr-xr-xroles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh17
-rw-r--r--roles/openshift_node_dnsmasq/handlers/main.yml4
-rw-r--r--roles/openshift_node_dnsmasq/meta/main.yml2
-rw-r--r--roles/openshift_node_dnsmasq/tasks/main.yml15
4 files changed, 22 insertions, 16 deletions
diff --git a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
index ced0fa663..089c3f7e4 100755
--- a/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
+++ b/roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh
@@ -28,7 +28,7 @@ cd /etc/sysconfig/network-scripts
[ -f ../network ] && . ../network
-if [[ $2 =~ ^(up|dhcp4-change)$ ]]; then
+if [[ $2 =~ ^(up|dhcp4-change|dhcp6-change)$ ]]; then
# If the origin-upstream-dns config file changed we need to restart
NEEDS_RESTART=0
UPSTREAM_DNS='/etc/dnsmasq.d/origin-upstream-dns.conf'
@@ -36,6 +36,7 @@ if [[ $2 =~ ^(up|dhcp4-change)$ ]]; then
UPSTREAM_DNS_TMP=`mktemp`
UPSTREAM_DNS_TMP_SORTED=`mktemp`
CURRENT_UPSTREAM_DNS_SORTED=`mktemp`
+ NEW_RESOLV_CONF=`mktemp`
######################################################################
# couldn't find an existing method to determine if the interface owns the
@@ -85,13 +86,17 @@ EOF
systemctl restart dnsmasq
fi
- sed -i '0,/^nameserver/ s/^nameserver.*$/nameserver '"${def_route_ip}"'/g' /etc/resolv.conf
-
- if ! grep -q '99-origin-dns.sh' /etc/resolv.conf; then
- echo "# nameserver updated by /etc/NetworkManager/dispatcher.d/99-origin-dns.sh" >> /etc/resolv.conf
+ # Only if dnsmasq is running properly make it our only nameserver
+ if `systemctl -q is-active dnsmasq.service`; then
+ sed -e '/^nameserver.*$/d' /etc/resolv.conf > ${NEW_RESOLV_CONF}
+ echo "nameserver "${def_route_ip}"" >> ${NEW_RESOLV_CONF}
+ if ! grep -q '99-origin-dns.sh' ${NEW_RESOLV_CONF}; then
+ echo "# nameserver updated by /etc/NetworkManager/dispatcher.d/99-origin-dns.sh" >> ${NEW_RESOLV_CONF}
+ fi
+ cp -Z ${NEW_RESOLV_CONF} /etc/resolv.conf
fi
fi
# Clean up after yourself
- rm -f $UPSTREAM_DNS_TMP $UPSTREAM_DNS_TMP_SORTED $CURRENT_UPSTREAM_DNS_SORTED
+ rm -f $UPSTREAM_DNS_TMP $UPSTREAM_DNS_TMP_SORTED $CURRENT_UPSTREAM_DNS_SORTED $NEW_RESOLV_CONF
fi
diff --git a/roles/openshift_node_dnsmasq/handlers/main.yml b/roles/openshift_node_dnsmasq/handlers/main.yml
index 7d43b6106..b4a0c3583 100644
--- a/roles/openshift_node_dnsmasq/handlers/main.yml
+++ b/roles/openshift_node_dnsmasq/handlers/main.yml
@@ -1,10 +1,10 @@
---
- name: restart NetworkManager
- service:
+ systemd:
name: NetworkManager
state: restarted
- name: restart dnsmasq
- service:
+ systemd:
name: dnsmasq
state: restarted
diff --git a/roles/openshift_node_dnsmasq/meta/main.yml b/roles/openshift_node_dnsmasq/meta/main.yml
index c83d64ae4..18e04e06d 100644
--- a/roles/openshift_node_dnsmasq/meta/main.yml
+++ b/roles/openshift_node_dnsmasq/meta/main.yml
@@ -4,7 +4,7 @@ galaxy_info:
description: OpenShift Node DNSMasq support
company: Red Hat, Inc.
license: Apache License, Version 2.0
- min_ansible_version: 1.7
+ min_ansible_version: 2.2
platforms:
- name: EL
versions:
diff --git a/roles/openshift_node_dnsmasq/tasks/main.yml b/roles/openshift_node_dnsmasq/tasks/main.yml
index 396c27295..3311f7006 100644
--- a/roles/openshift_node_dnsmasq/tasks/main.yml
+++ b/roles/openshift_node_dnsmasq/tasks/main.yml
@@ -4,13 +4,14 @@
systemctl show NetworkManager
register: nm_show
changed_when: false
+ ignore_errors: True
- name: Set fact using_network_manager
set_fact:
network_manager_active: "{{ True if 'ActiveState=active' in nm_show.stdout else False }}"
- name: Install dnsmasq
- action: "{{ ansible_pkg_mgr }} name=dnsmasq state=installed"
+ package: name=dnsmasq state=installed
when: not openshift.common.is_atomic | bool
- name: Install dnsmasq configuration
@@ -21,16 +22,16 @@
- name: Deploy additional dnsmasq.conf
template:
- src: "{{ openshift_node_dnsmasq_additional_config_file }}"
- dest: /etc/dnsmasq.d/openshift-ansible.conf
- owner: root
- group: root
- mode: 0644
+ src: "{{ openshift_node_dnsmasq_additional_config_file }}"
+ dest: /etc/dnsmasq.d/openshift-ansible.conf
+ owner: root
+ group: root
+ mode: 0644
when: openshift_node_dnsmasq_additional_config_file is defined
notify: restart dnsmasq
- name: Enable dnsmasq
- service:
+ systemd:
name: dnsmasq
enabled: yes
state: started