diff --git a/tasks/main.yml b/tasks/main.yml index e45442f..edafcdb 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,13 +1,25 @@ --- +- 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 @@ -16,20 +28,24 @@ - 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 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 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 + 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