Skip to content

Commit b321a60

Browse files
committed
More changes
1 parent bd0ccf6 commit b321a60

File tree

8 files changed

+50
-17
lines changed

8 files changed

+50
-17
lines changed

playbooks/common/openshift-node/configure_nodes.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
roles:
1414
- role: os_firewall
1515
- role: openshift_node
16+
- role: openshift_node_dnsmasq
1617
- role: tuned
1718
- role: nickhammond.logrotate

roles/openshift_node/meta/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ dependencies:
1818
- role: openshift_clock
1919
- role: openshift_docker
2020
- role: openshift_cloud_provider
21-
- role: openshift_node_dnsmasq

roles/openshift_node/templates/node.service.j2

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ After=dnsmasq.service
1414
Type=notify
1515
EnvironmentFile=/etc/sysconfig/{{ openshift.common.service_type }}-node
1616
Environment=GOTRACEBACK=crash
17-
ExecStartPre=/usr/bin/cp /etc/origin/node/node-dnsmasq.conf /etc/dnsmasq.d/
17+
{% if not openshift.common.version_gte_3_7 %}
18+
ExecStartPre=-/usr/bin/cp /etc/origin/node/node-dnsmasq.conf /etc/dnsmasq.d/
1819
ExecStartPre=/usr/bin/dbus-send --system --dest=uk.org.thekelleys.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers array:string:/in-addr.arpa/127.0.0.1,/{{ openshift.common.dns_domain }}/127.0.0.1
19-
ExecStopPost=/usr/bin/rm /etc/dnsmasq.d/node-dnsmasq.conf
20+
ExecStopPost=-/usr/bin/rm /etc/dnsmasq.d/node-dnsmasq.conf
2021
ExecStopPost=/usr/bin/dbus-send --system --dest=uk.org.thekelleys.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers array:string:
22+
{% endif %}
2123
ExecStart=/usr/bin/openshift start node --config=${CONFIG_FILE} $OPTIONS
2224
LimitNOFILE=65536
2325
LimitCORE=infinity

roles/openshift_node/templates/node.yaml.v1.j2

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
allowDisabledDocker: false
22
apiVersion: v1
3-
{% if openshift.common.version_gte_3_6 %}
4-
dnsBindAddress: 127.0.0.1:53
5-
dnsRecursiveResolvConf: /etc/origin/node/resolv.conf
6-
{% endif %}
73
dnsDomain: {{ openshift.common.dns_domain }}
84
{% if 'dns_ip' in openshift.node %}
95
dnsIP: {{ openshift.node.dns_ip }}

roles/openshift_node/templates/openshift.docker.node.service

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ After=dnsmasq.service
2020
EnvironmentFile=/etc/sysconfig/{{ openshift.common.service_type }}-node
2121
EnvironmentFile=/etc/sysconfig/{{ openshift.common.service_type }}-node-dep
2222
ExecStartPre=-/usr/bin/docker rm -f {{ openshift.common.service_type }}-node
23-
ExecStartPre=/usr/bin/cp /etc/origin/node/node-dnsmasq.conf /etc/dnsmasq.d/
23+
{% if not openshift.common.version_gte_3_7 %}
24+
ExecStartPre=-/usr/bin/cp /etc/origin/node/node-dnsmasq.conf /etc/dnsmasq.d/
2425
ExecStartPre=/usr/bin/dbus-send --system --dest=uk.org.thekelleys.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers array:string:/in-addr.arpa/127.0.0.1,/{{ openshift.common.dns_domain }}/127.0.0.1
26+
ExecStopPost=-/usr/bin/rm /etc/dnsmasq.d/node-dnsmasq.conf
27+
ExecStopPost=/usr/bin/dbus-send --system --dest=uk.org.thekelleys.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers array:string:
28+
{% endif %}
2529
ExecStart=/usr/bin/docker run --name {{ openshift.common.service_type }}-node \
2630
--rm --privileged --net=host --pid=host --env-file=/etc/sysconfig/{{ openshift.common.service_type }}-node \
2731
-v /:/rootfs:ro,rslave -e CONFIG_FILE=${CONFIG_FILE} -e OPTIONS=${OPTIONS} \
@@ -41,8 +45,6 @@ ExecStart=/usr/bin/docker run --name {{ openshift.common.service_type }}-node \
4145
{{ openshift.node.node_image }}:${IMAGE_VERSION}
4246
ExecStartPost=/usr/bin/sleep 10
4347
ExecStop=/usr/bin/docker stop {{ openshift.common.service_type }}-node
44-
ExecStopPost=/usr/bin/rm /etc/dnsmasq.d/node-dnsmasq.conf
45-
ExecStopPost=/usr/bin/dbus-send --system --dest=uk.org.thekelleys.dnsmasq /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetDomainServers array:string:
4648
SyslogIdentifier={{ openshift.common.service_type }}-node
4749
Restart=always
4850
RestartSec=5s

roles/openshift_node_dnsmasq/files/networkmanager/99-origin-dns.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323

2424
cd /etc/sysconfig/network-scripts
2525
. ./network-functions
26+
. /etc/sysconfig/atomic-openshift-node
2627

2728
[ -f ../network ] && . ../network
2829

2930
if [[ $2 =~ ^(up|dhcp4-change|dhcp6-change)$ ]]; then
3031
NEEDS_RESTART=0
3132
NEW_RESOLV_CONF=`mktemp`
32-
33+
if [ ! -f /etc/origin/node/resolv.conf ]; then
34+
cp /etc/resolv.conf /etc/origin/node/resolv.conf
35+
fi
3336
######################################################################
3437
# couldn't find an existing method to determine if the interface owns the
3538
# default route
@@ -41,11 +44,18 @@ if [[ $2 =~ ^(up|dhcp4-change|dhcp6-change)$ ]]; then
4144
cat << EOF > /etc/dnsmasq.d/origin-dns.conf
4245
domain-needed
4346
enable-dbus
44-
bind-dynamic
45-
except-interface=lo
47+
bind-interfaces
4648
dns-loop-detect
4749
resolv-file=/etc/origin/node/resolv.conf
4850
EOF
51+
if [ -z OPENSHIFT_NODE_DNSMASQ_INTERFACES ]; then
52+
for i in OPENSHIFT_NODE_DNSMASQ_INTERFACES; do
53+
echo "interface=${i}" >> /etc/dnsmasq.d/origin-dns.conf
54+
done
55+
else
56+
echo "except-interface=lo" >> /etc/dnsmasq.d/origin-dns.conf
57+
fi
58+
4959
# New config file, must restart
5060
NEEDS_RESTART=1
5161
fi
@@ -59,10 +69,6 @@ EOF
5969
if [ "${NEEDS_RESTART}" -eq "1" ]; then
6070
systemctl restart dnsmasq
6171
fi
62-
63-
if [ ! -f /etc/origin/node/resolv.conf ]; then
64-
cp /etc/resolv.conf /etc/origin/node/resolv.conf
65-
fi
6672

6773
# Only if dnsmasq is running properly make it our only nameserver and place
6874
# a watermark on /etc/resolv.conf

roles/openshift_node_dnsmasq/tasks/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,14 @@
4747
# Relies on ansible in order to configure static config
4848
- include: ./no-network-manager.yml
4949
when: not network_manager_active | bool
50+
51+
- name: Reconfigure the node for dnsmasq
52+
yedit:
53+
src: /etc/origin/node/node-config.yaml
54+
key: "{{ item.key }}"
55+
value: "{{ item.value }}"
56+
with_items:
57+
- key: "dnsBindAddress"
58+
value: "127.0.0.1:53"
59+
- key: "dnsRecursiveResolvConf"
60+
value: "/etc/origin/node/resolv.conf"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
---
2+
3+
- name: Configured dnsmasq interfaces
4+
lineinfile:
5+
path: /etc/sysconfig/atomic-openshift-node
6+
line: "OPENSHIFT_NODE_DNSMASQ_INTERFACES={{ openshift_node_dnsmasq_interfaces | join (',') }}"
7+
notify: restart NetworkManager
8+
when: openshift_node_dnsmasq_interfaces is defined
9+
210
- name: Install network manager dispatch script
311
copy:
412
src: networkmanager/99-origin-dns.sh
513
dest: /etc/NetworkManager/dispatcher.d/
614
mode: 0755
715
notify: restart NetworkManager
16+
17+
- name: Ensure dnsmasq can read /etc/origin/node/resolv.conf
18+
file:
19+
path: "{{ item }}"
20+
mode: "o+x"
21+
with_items:
22+
- "/etc/origin"
23+
- "/etc/origin/node"
824

925
- meta: flush_handlers

0 commit comments

Comments
 (0)