diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-03-07 07:00:49 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-03-07 07:00:49 +0100 |
commit | d1fcbd7a9a8511b895f9a163f7fa2a7bc0d72f2b (patch) | |
tree | 2d55aa341e16906701759190ff7aec35fefcc443 | |
parent | a4b7b59da63e0f240e43796469465bdda2042d05 (diff) | |
download | openshift-d1fcbd7a9a8511b895f9a163f7fa2a7bc0d72f2b.tar.gz openshift-d1fcbd7a9a8511b895f9a163f7fa2a7bc0d72f2b.tar.bz2 openshift-d1fcbd7a9a8511b895f9a163f7fa2a7bc0d72f2b.tar.xz openshift-d1fcbd7a9a8511b895f9a163f7fa2a7bc0d72f2b.zip |
Fix NetworkManager hook to support OpenShift running on non-default network interface
-rw-r--r-- | roles/openshift_node/files/bootstrap.yml | 2 | ||||
-rwxr-xr-x | roles/openshift_node/files/networkmanager/99-origin-dns.sh | 23 |
2 files changed, 20 insertions, 5 deletions
diff --git a/roles/openshift_node/files/bootstrap.yml b/roles/openshift_node/files/bootstrap.yml index ea280640f..df95ba360 100644 --- a/roles/openshift_node/files/bootstrap.yml +++ b/roles/openshift_node/files/bootstrap.yml @@ -8,7 +8,7 @@ lines: - regex: ^listen-address state: present - line: "listen-address={{ ansible_default_ipv4.address }}" + line: "listen-address={{ openshift_dns_ip }}" node_dns: file: /etc/dnsmasq.d/node-dnsmasq.conf lines: diff --git a/roles/openshift_node/files/networkmanager/99-origin-dns.sh b/roles/openshift_node/files/networkmanager/99-origin-dns.sh index acf3e2f38..16129a288 100755 --- a/roles/openshift_node/files/networkmanager/99-origin-dns.sh +++ b/roles/openshift_node/files/networkmanager/99-origin-dns.sh @@ -43,10 +43,25 @@ if [[ $2 =~ ^(up|dhcp4-change|dhcp6-change)$ ]]; then ###################################################################### # couldn't find an existing method to determine if the interface owns the # default route - def_route=$(/sbin/ip route list match 0.0.0.0/0 | awk '{print $3 }') - def_route_int=$(/sbin/ip route get to ${def_route} | awk '{print $3}') - def_route_ip=$(/sbin/ip route get to ${def_route} | awk '{print $5}') - if [[ ${DEVICE_IFACE} == ${def_route_int} ]]; then + #SDS + #def_route=$(/sbin/ip route list match 0.0.0.0/0 | awk '{print $3 }') + #def_route_int=$(/sbin/ip route get to ${def_route} | awk '{print $3}') + #def_route_ip=$(/sbin/ip route get to ${def_route} | awk '{print $5}') + #EDS + def_route_ip=$(cat /etc/hosts | grep openshift_dns_ip | awk '{ print $1 }') + [ -n "$def_route_ip" ] && def_route_int=$(ip -o addr show | grep ${def_route_ip} | awk '{ print $2 }') + if [ -z "$def_route_ip" -o -z "$def_route_int" ]; then + def_route=$(/sbin/ip route list match 0.0.0.0/0 | awk '{print $3 }') + def_route_int=$(/sbin/ip route get to ${def_route} | awk '{print $3}' | head -n 1) + def_route_ip=$(/sbin/ip -f inet addr show dev ${def_route_int} scope global up | grep -Po 'inet \K[\d.]+' | head -n 1) + fi + + def_routes=$(/sbin/ip route list match 0.0.0.0/0 | awk '{print $3 }') + def_routes_int=$(for r in ${def_routes}; do /sbin/ip route get to ${r} | awk '{print $3}'; done) + interfaces="${def_route_int} ${def_routes_int}" + + if [[ "${interfaces}" =~ (^|[[:space:]])${DEVICE_IFACE}($|[[:space:]]) ]]; then +# if [[ ${DEVICE_IFACE} == ${def_route_int} ]]; then if [ ! -f /etc/dnsmasq.d/origin-dns.conf ]; then cat << EOF > /etc/dnsmasq.d/origin-dns.conf no-resolv |