From dc0bbede29a94768d916f9aff932ed57638df815 Mon Sep 17 00:00:00 2001 From: Martin Kolly Date: Tue, 13 Oct 2015 08:49:34 +0200 Subject: [PATCH 1/2] add os specific variables --- tasks/main.yml | 26 +++++++++++++++++++++----- vars/Debian.yml | 9 +++++++++ vars/RedHat.yml | 9 +++++++++ vars/main.yml | 7 ------- 4 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 vars/Debian.yml create mode 100644 vars/RedHat.yml diff --git a/tasks/main.yml b/tasks/main.yml index e45442f..c93c881 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,35 +1,51 @@ --- +- name: Add the OS specific variables + include_vars: '{{ ansible_os_family }}.yml' + - name: install bind packages apt: pkg={{ item }} state={{ bind_pkg_state }} with_items: bind_pkgs + when: ansible_os_family == 'Debian' + tags: package + +- name: install bind packages + yum: pkg={{ item }} state={{ bind_pkg_state }} + with_items: bind_pkgs + when: ansible_os_family == 'RedHat' + tags: package - name: setup zone directories file: dest={{ bind_base_zones_path }}/{{ item }} state=directory owner={{ bind_user }} group={{ bind_group }} mode=0755 with_items: - masters - slaves + tags: configuration - name: setup zones - template: src=named.conf.local.{{ item }}.j2 dest={{ bind_config_basepath }}/named.conf.local.{{ item }} owner={{ bind_user }} group={{ bind_group }} mode=0600 + action: template src=named.conf.local.{{ item }}.j2 dest={{ bind_config_basepath }}/named.conf.local.{{ item }} owner={{ bind_user }} group={{ bind_group }} mode=0600 with_items: - master - slave - forward notify: reload bind + tags: configuration - name: configure bind - copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 + copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 #validate='named-checkconf %s' backup=yes notify: restart bind + tags: configuration - name: configure bind options - template: src=named.conf.options.j2 dest={{ bind_config_basepath }}/named.conf.options owner={{ bind_user }} group={{ bind_group }} mode=0600 + template: src=named.conf.options.j2 dest={{ bind_config_basepath }}/named.conf.options owner={{ bind_user }} group={{ bind_group }} mode=0600 backup=yes notify: restart bind + tags: configuration - name: Copy master zone files copy: src={{ bind_masterzones_path }}/db.{{ item.name }} dest={{ bind_base_zones_path }}/{{bind_masterzones_path}} owner={{ bind_user }} group={{ bind_group }} with_items: bind_config_master_zones - notify: reload bind - tags: bind-zones + notify: restart bind + tags: zones - name: start/stop bind service service: name={{ bind_service_name }} state={{ bind_service_state }} enabled={{ bind_service_enabled }} + tags: service diff --git a/vars/Debian.yml b/vars/Debian.yml new file mode 100644 index 0000000..3e75701 --- /dev/null +++ b/vars/Debian.yml @@ -0,0 +1,9 @@ +--- +bind_config_basepath: /etc/bind +bind_user: bind +bind_group: bind +bind_service_name: bind9 +bind_pkgs: + - bind9 + - dnsutils + diff --git a/vars/RedHat.yml b/vars/RedHat.yml new file mode 100644 index 0000000..1d41629 --- /dev/null +++ b/vars/RedHat.yml @@ -0,0 +1,9 @@ +--- +bind_config_basepath: /etc/named +bind_user: named +bind_group: named +bind_service_name: named +bind_pkgs: + - bind + - bind-utils + diff --git a/vars/main.yml b/vars/main.yml index cefd270..ed97d53 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,8 +1 @@ --- -bind_config_basepath: /etc/bind -bind_user: bind -bind_group: bind -bind_service_name: bind9 -bind_pkgs: - - bind9 - - dnsutils From 9bc698b51f13a49d408d963b70fde63b6d788ab5 Mon Sep 17 00:00:00 2001 From: Martin Kolly Date: Tue, 13 Oct 2015 08:59:36 +0200 Subject: [PATCH 2/2] restore changes --- tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index c93c881..edafcdb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -22,7 +22,7 @@ tags: configuration - name: setup zones - action: template src=named.conf.local.{{ item }}.j2 dest={{ bind_config_basepath }}/named.conf.local.{{ item }} owner={{ bind_user }} group={{ bind_group }} mode=0600 + template: src=named.conf.local.{{ item }}.j2 dest={{ bind_config_basepath }}/named.conf.local.{{ item }} owner={{ bind_user }} group={{ bind_group }} mode=0600 with_items: - master - slave @@ -31,19 +31,19 @@ tags: configuration - name: configure bind - copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 #validate='named-checkconf %s' backup=yes + copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 notify: restart bind tags: configuration - name: configure bind options - template: src=named.conf.options.j2 dest={{ bind_config_basepath }}/named.conf.options owner={{ bind_user }} group={{ bind_group }} mode=0600 backup=yes + template: src=named.conf.options.j2 dest={{ bind_config_basepath }}/named.conf.options owner={{ bind_user }} group={{ bind_group }} mode=0600 notify: restart bind tags: configuration - name: Copy master zone files copy: src={{ bind_masterzones_path }}/db.{{ item.name }} dest={{ bind_base_zones_path }}/{{bind_masterzones_path}} owner={{ bind_user }} group={{ bind_group }} with_items: bind_config_master_zones - notify: restart bind + notify: reload bind tags: zones - name: start/stop bind service