Skip to content

Commit

Permalink
- Remove NetworkManager
Browse files Browse the repository at this point in the history
- Forget about DNS configuration provided by cloud
- Disable /etc/resolv.conf modification by dhclient
- Fix issue when kube-proxy is not started after reboot
  • Loading branch information
altvnk committed Aug 21, 2015
1 parent 579f9cb commit 9951bd8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 55 deletions.
4 changes: 0 additions & 4 deletions roles/dnsmasq/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
---
- name: restart networkmanager
sudo: yes
command: systemctl restart NetworkManager

- name: restart dnsmasq
sudo: yes
command: systemctl restart dnsmasq
58 changes: 11 additions & 47 deletions roles/dnsmasq/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,10 @@
tags:
- dnsmasq

- name: install networkmanager
sudo: yes
yum:
name: NetworkManager
state: latest
tags:
- dnsmasq

- name: collect nameservers
sudo: yes
shell: "cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2"
register: nameservers_output
tags:
- dnsmasq

- name: collect dns search list
sudo: yes
shell: "cat /etc/resolv.conf | grep -i '^search' | cut -d ' ' -f2- | tr ' ' '\n'"
register: dns_search_list_output
tags:
- dnsmasq

- name: set nameservers
set_fact:
nameservers_list: "{{ nameservers_output.stdout_lines }}"
tags:
- dnsmasq

- name: set dns search list
set_fact:
domain_search_list: "{{ dns_search_list_output.stdout_lines }}"
tags:
- dnsmasq

- name: ensure dnsmasq.d directory exists
sudo: yes
file:
path: /etc/NetworkManager/dnsmasq.d
path: /etc/dnsmasq.d
state: directory
when: inventory_hostname in groups[master_group_name]
tags:
Expand Down Expand Up @@ -76,23 +42,21 @@
tags:
- dnsmasq

- name: disable NetworkManager DNS config
sudo: yes
ini_file:
dest: /etc/NetworkManager/NetworkManager.conf
section: main
option: dns
value: none
notify:
- restart networkmanager
tags:
- dnsmasq

- name: update resolv.conf with new DNS setup
sudo: yes
template:
src: resolv.conf.j2
dest: /etc/resolv.conf
mode: 644
tags:
- dnsmasq

- name: disable resolv.conf modification by dhclient
sudo: yes
lineinfile:
dest: "/etc/sysconfig/network-scripts/ifcfg-{{ ansible_default_ipv4.interface }}"
state: present
regexp: '^PEERDNS'
line: 'PEERDNS="no"'
tags:
- dnsmasq
5 changes: 1 addition & 4 deletions roles/dnsmasq/templates/resolv.conf.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
; generated by ansible
search {{ [ 'default.svc.' + dns_domain, 'svc.' + dns_domain, dns_domain ] | union(domain_search_list) | unique | join(' ') }}
search {{ [ 'default.svc.' + dns_domain, 'svc.' + dns_domain, dns_domain ] | join(' ') }}
{% for host in groups[master_group_name] %}
nameserver {{ hostvars[host]['ansible_default_ipv4']['address'] }}
{% endfor %}
{% for nameserver in nameservers_list | unique %}
nameserver {{ nameserver }}
{% endfor %}
9 changes: 9 additions & 0 deletions roles/master/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,14 @@
name: kube-scheduler
enabled: yes
state: started
tags:
- master

- name: Enable kube-proxy
sudo: yes
service:
name: kube-proxy
enabled: yes
state: started
tags:
- master

0 comments on commit 9951bd8

Please sign in to comment.