From 44bece4b1de5c9a287ee708cec63b6adc2ff9e88 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Sat, 21 May 2016 21:06:18 +0200 Subject: [PATCH] - Added DNS auto-configuration - Tests on Ubuntu 14.04 --- README.md | 4 +++- handlers/main.yml | 5 ++++- tasks/main.yml | 32 +++++++++++++++++++++++++++++--- templates/hostname.dnsmasq.j2 | 1 + templates/resolv.conf.j2 | 2 +- vars/Ubuntu.yml | 2 ++ 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 templates/hostname.dnsmasq.j2 diff --git a/README.md b/README.md index 8b40107..92beb5d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Requirements * CentOS 6, 7 * RHEL 6, 7 * Ubuntu 14.04 -* Correctly configure DNS +* Correctly configure DNS : now auto-configured using dnsmasq * Correctly configued `/etc/hosts` file : now auto-configured by this ansible role Role Variables @@ -94,3 +94,5 @@ Author Information ------------------ Based on ansible-zimbradev by pbruna + +Modified by paulbsd diff --git a/handlers/main.yml b/handlers/main.yml index fc6b3c5..0215729 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -2,4 +2,7 @@ # handlers file for cartertdte.mta - name: postfix restart - service: name=postfix state=restarted \ No newline at end of file + service: name=postfix state=restarted + +- name: dnsmasq restart + service: name=dnsmasq state=restarted diff --git a/tasks/main.yml b/tasks/main.yml index 8e86286..e32a9c6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,13 +21,38 @@ src=hosts.j2 dest=/etc/hosts owner=root + group=root mode=0644 + notify: + - dnsmasq restart -- name: Disable and stop dnsmasq service +- name: Set resolv.conf file + template: + src=resolv.conf.j2 + dest=/etc/resolv.conf + owner=root + group=root + mode=0644 + notify: + - dnsmasq restart + +- name: Resolv self hostname via dnsmasq + template: + src=hostname.dnsmasq.j2 + dest=/etc/dnsmasq.d/{{ ansible_hostname }} + owner=root + group=root + mode=0644 + notify: + - dnsmasq restart + +- name: Enable dnsmasq service service: name=dnsmasq - state=stopped - enabled=no + enabled=yes + +- name: Ensure handlers run now + meta: flush_handlers - name: Create Source Software Directory file: path=/opt/src state=directory @@ -56,5 +81,6 @@ - name: Start zimbra service: name=zimbra state=restarted + ignore_errors: yes - include: provision_zimbra.yml diff --git a/templates/hostname.dnsmasq.j2 b/templates/hostname.dnsmasq.j2 new file mode 100644 index 0000000..c1593d1 --- /dev/null +++ b/templates/hostname.dnsmasq.j2 @@ -0,0 +1 @@ +address=/{{ zimbra_hostname }}.{{ zimbra_default_domain }}/{{ ansible_eth0.ipv4.address }} diff --git a/templates/resolv.conf.j2 b/templates/resolv.conf.j2 index c744ebe..8243de5 100644 --- a/templates/resolv.conf.j2 +++ b/templates/resolv.conf.j2 @@ -1,2 +1,2 @@ -search localdomain ffx.net +search localdomain {{ zimbra_default_domain }} nameserver 127.0.0.1 diff --git a/vars/Ubuntu.yml b/vars/Ubuntu.yml index 1a03e7c..86ce5e1 100644 --- a/vars/Ubuntu.yml +++ b/vars/Ubuntu.yml @@ -10,9 +10,11 @@ zimbra_required_packages: - unzip - perl - libperl5.18 + - netcat-openbsd - pax - sysstat - sqlite3 - resolvconf - dnsmasq + - dnsutils - wget