Skip to content

Commit

Permalink
Add optional local DNS: unbound
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilien Mantel committed Jul 28, 2015
1 parent 6a544c1 commit 88af812
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This role bootstraps Debian server:
- Configure APT (sources.list)
- Install minimal packages (vim, htop...)
- Install Intel/AMD microcode if needed
- Install and configure Local DNS with [Unbound](https://www.unbound.net). Feature in beta-test!
- Install and configure [OpenNTPd](http://www.openntpd.org/)
- Add user with SSH key, sudoers
- Deploy bashrc, vimrc for root
Expand Down Expand Up @@ -38,6 +39,7 @@ Theses variables define hostname to configure APT (normal repo and backports):
- `dbs_timezone`: system timezone
- `dbs_sysctl_config: list of kernel parameters, see`: [default/main.yml]
- `dbs_use_systemd`: delete systemd if set to false (persistent)
- `dbs_use_unbound`: configure Local DNS and manage network (default is false)

### NTPd

Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dbs_locales:
dbs_default_locale: 'en_US.UTF-8'
dbs_timezone: 'Europe/Paris'
dbs_use_systemd: false
dbs_use_unbound: false

# -------------------------
# NTPd configuration
Expand Down
3 changes: 3 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

- name: locale-gen
command: locale-gen

- name: reload networking
action: service name=networking state=reloaded
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

- include: apt.yml

- include: unbound.yml
when: dbs_use_unbound

- include: nosystemd.yml
when: (ansible_distribution_major_version | version_compare(7, 'gt')) and (not dbs_use_systemd)

Expand Down
17 changes: 17 additions & 0 deletions tasks/unbound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---

- name: APT | Install Unbound
apt: pkg=unbound state=latest

- name: REPLACE | Apply dns configuration to /etc/network/interfaces if necessary
replace: dest=/etc/network/interfaces regexp='^\s+dns-nameservers' replace='\tdns-nameservers 127.0.0.1'
notify: reload networking

- name: STAT | Check if DHCP client config
stat: path=/etc/dhcp/dhclient.conf
register: dhcp

- name: LINEINFILE | Prepend DNS config on DHCP
lineinfile: dest=/etc/dhcp/dhclient.conf line='prepend domain-name-servers 127.0.0.1;'
when: dhcp.stat.exists
notify: reload networking
1 change: 1 addition & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- hosts: all
vars:
dbs_use_unbound: true
dbs_users:
- name: hanx
sudo: true
Expand Down

0 comments on commit 88af812

Please sign in to comment.