diff --git a/molecule/pdns-42/molecule.yml b/molecule/pdns-42/molecule.yml index 8d1ddab..d778085 100644 --- a/molecule/pdns-42/molecule.yml +++ b/molecule/pdns-42/molecule.yml @@ -19,12 +19,10 @@ platforms: image: centos:7 dockerfile_tpl: centos-systemd - # Temporarely disable CentOS 8 due to: - # https://github.com/ansible/ansible/issues/64963 - # - name: centos-8 - # groups: ["pdns"] - # image: centos:8 - # dockerfile_tpl: centos-systemd + - name: centos-8 + groups: ["pdns"] + image: centos:8 + dockerfile_tpl: centos-systemd - name: ubuntu-1804 groups: ["pdns"] diff --git a/molecule/pdns-43/molecule.yml b/molecule/pdns-43/molecule.yml index f058e06..fa454e0 100644 --- a/molecule/pdns-43/molecule.yml +++ b/molecule/pdns-43/molecule.yml @@ -19,12 +19,10 @@ platforms: image: centos:7 dockerfile_tpl: centos-systemd - # Temporarely disable CentOS 8 due to: - # https://github.com/ansible/ansible/issues/64963 - # - name: centos-8 - # groups: ["pdns"] - # image: centos:8 - # dockerfile_tpl: centos-systemd + - name: centos-8 + groups: ["pdns"] + image: centos:8 + dockerfile_tpl: centos-systemd - name: ubuntu-1804 groups: ["pdns"] diff --git a/molecule/pdns-master/molecule.yml b/molecule/pdns-master/molecule.yml index 6fa920f..9afb8d8 100644 --- a/molecule/pdns-master/molecule.yml +++ b/molecule/pdns-master/molecule.yml @@ -19,12 +19,10 @@ platforms: image: centos:7 dockerfile_tpl: centos-systemd - # Temporarely disable CentOS 8 due to: - # https://github.com/ansible/ansible/issues/64963 - # - name: centos-8 - # groups: ["pdns"] - # image: centos:8 - # dockerfile_tpl: centos-systemd + - name: centos-8 + groups: ["pdns"] + image: centos:8 + dockerfile_tpl: centos-systemd - name: ubuntu-1804 groups: ["pdns"] diff --git a/tasks/database-mysql.yml b/tasks/database-mysql.yml index 7f9d91f..f687851 100644 --- a/tasks/database-mysql.yml +++ b/tasks/database-mysql.yml @@ -1,21 +1,9 @@ --- -- name: Install the MySQL dependencies on RedHat +- name: Install the MySQL dependencies package: - name: - - mysql - - MySQL-python + name: "{{ pdns_mysql_packages }}" state: present - when: ansible_os_family == 'RedHat' - -- name: Install the MySQL dependencies on Debian - package: - name: - - default-mysql-client - - python-mysqldb - - python3-mysqldb - state: present - when: ansible_os_family == 'Debian' - name: Create the PowerDNS MySQL databases mysql_db: @@ -66,9 +54,16 @@ - name: Define the PowerDNS database MySQL schema file path on RedHat >= 7 or PowerDNS >= 4.2.0 set_fact: _pdns_mysql_schema_file: "/usr/share/doc/pdns-backend-mysql-{{ _pdns_running_version }}/schema.mysql.sql" - when: ansible_distribution_major_version | int >= 7 + when: ansible_distribution_major_version | int == 7 or _pdns_running_version is version_compare('4.2.0', '>=') + - name: Define the PowerDNS database MySQL schema file path on RedHat 8 and PowerDNS >= 4.2.0 + set_fact: + _pdns_mysql_schema_file: "/usr/share/doc/pdns-backend-mysql/schema.mysql.sql" + when: + - ansible_distribution_major_version | int == 8 + - _pdns_running_version is version_compare('4.2.0', '>=') + when: ansible_os_family == 'RedHat' - block: diff --git a/tasks/database-sqlite3.yml b/tasks/database-sqlite3.yml index 28ebd9c..476e4f1 100644 --- a/tasks/database-sqlite3.yml +++ b/tasks/database-sqlite3.yml @@ -22,22 +22,30 @@ with_items: "{{ pdns_sqlite_databases_locations }}" - block: - - - name: Create the PowerDNS SQLite databases on RedHat < 7 and PowerDNS < 4.2.0 - shell: "sqlite3 {{ item }} < /usr/share/doc/pdns/schema.sqlite3.sql" - args: - creates: "{{ item }}" - with_items: "{{ pdns_sqlite_databases_locations }}" + - name: Define the PowerDNS SQLite schema file path on RedHat < 7 and PowerDNS < 4.2.0 + set_fact: + _pdns_mysql_schema_file: "/usr/share/doc/pdns/schema.sqlite3.sql" when: ansible_distribution_major_version | int < 7 and _pdns_running_version is version_compare('4.2.0', '<') - - name: Create the PowerDNS SQLite databases on RedHat >= 7 or PowerDNS >= 4.2.0 - shell: "sqlite3 {{ item }} < /usr/share/doc/pdns-backend-sqlite-{{ _pdns_running_version }}/schema.sqlite3.sql" + - name: Define the PowerDNS SQLite schema file path on RedHat >= 7 or PowerDNS >= 4.2.0 + set_fact: + _pdns_mysql_schema_file: "/usr/share/doc/pdns-backend-sqlite-{{ _pdns_running_version }}/schema.sqlite3.sql" + when: ansible_distribution_major_version | int == 7 + or _pdns_running_version is version_compare('4.2.0', '>=') + + - name: Define the PowerDNS SQLite schema file path on RedHat 8 and PowerDNS >= 4.2.0 + set_fact: + _pdns_mysql_schema_file: "/usr/share/doc/pdns-backend-sqlite/schema.sqlite3.sql" + when: + - ansible_distribution_major_version | int == 8 + - _pdns_running_version is version_compare('4.2.0', '>=') + + - name: Create the PowerDNS SQLite databases on RedHat + shell: "sqlite3 {{ item }} < {{ _pdns_mysql_schema_file }}" args: creates: "{{ item }}" with_items: "{{ pdns_sqlite_databases_locations }}" - when: ansible_distribution_major_version | int >= 7 - or _pdns_running_version is version_compare('4.2.0', '>=') when: ansible_os_family == "RedHat" diff --git a/tasks/main.yml b/tasks/main.yml index 87db9a6..a6b8253 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,11 @@ --- - name: Include OS-specific variables - include_vars: "{{ ansible_os_family }}.yml" + include_vars: "{{ item }}" + with_first_found: + - "{{ ansible_os_family }}-{{ ansible_distribution_major_version }}.yml" + - "{{ ansible_distribution }}.yml" + - "{{ ansible_os_family }}.yml" tags: - always @@ -38,6 +42,12 @@ tags: - config +- include: selinux.yml + when: ansible_selinux is defined and ansible_selinux.status == 'enabled' + tags: + - selinux + - config + - name: Start and enable the PowerDNS service service: name: "{{ pdns_service_name }}" diff --git a/tasks/repo-RedHat.yml b/tasks/repo-RedHat.yml index cead543..09eaf5f 100644 --- a/tasks/repo-RedHat.yml +++ b/tasks/repo-RedHat.yml @@ -20,7 +20,9 @@ package: name: yum-plugin-priorities state: present - when: ansible_distribution in [ 'CentOS' ] + when: + - ansible_distribution in [ 'CentOS' ] + - ansible_distribution_major_version | int < 8 - name: Add the PowerDNS YUM Repository yum_repository: diff --git a/tasks/selinux.yml b/tasks/selinux.yml new file mode 100644 index 0000000..a7afcec --- /dev/null +++ b/tasks/selinux.yml @@ -0,0 +1,14 @@ +--- +- name: allow mysql connect from pdns in selinux + seboolean: + name: pdns_can_network_connect_db + state: yes + persistent: yes + when: "pdns_mysql_databases_credentials | length > 0" + +- name: allow pdns to bind to udp high ports + seport: + ports: 10000-20000 + proto: udp + setype: dns_port_t + state: present diff --git a/vars/Debian.yml b/vars/Debian.yml index 4e5174d..3cf0821 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -6,6 +6,12 @@ default_pdns_package_name: "pdns-server" # The name of the PowerDNS Authoritative Server debug package default_pdns_debug_symbols_package_name: "pdns-server-dbg" +# Packages needed to install MySQL +pdns_mysql_packages: + - default-mysql-client + - python-mysqldb + - python3-mysqldb + # List of PowerDNS Authoritative Server Backends packages on Debian default_pdns_backends_packages: geo: pdns-backend-geo diff --git a/vars/RedHat-8.yml b/vars/RedHat-8.yml new file mode 100644 index 0000000..eeac155 --- /dev/null +++ b/vars/RedHat-8.yml @@ -0,0 +1,33 @@ +--- + +# The name of the PowerDNS Authoritative Server package +default_pdns_package_name: "pdns" + +# Packages needed to install MySQL +pdns_mysql_packages: + - mariadb + - mariadb-server + - mariadb-connector-c + - python3-PyMySQL + - perl-DBD-MySQL + +# The name of the PowerDNS Authoritative Server debug package +default_pdns_debug_symbols_package_name: "pdns-debuginfo" + +# List of PowerDNS Authoritative Server backends packages on RedHat +default_pdns_backends_packages: + geo: pdns-backend-geo + geoip: pdns-backend-geoip + gmysql: pdns-backend-mysql + gpgsql: pdns-backend-postgresql + gsqlite3: pdns-backend-sqlite + ldap: pdns-backend-ldap + lmdb: pdns-backend-lmdb + lua: pdns-backend-lua + mydns: pdns-backend-mydns + pipe: pdns-backend-pipe + remote: pdns-backend-remote + tinydns: pdns-backend-tinydns + +# The directory where the PowerDNS Authoritative Server configuration is located +default_pdns_config_dir: "/etc/pdns" diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 8729d54..5e13780 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -3,6 +3,11 @@ # The name of the PowerDNS Authoritative Server package default_pdns_package_name: "pdns" +# Packages needed to install MySQL +pdns_mysql_packages: + - mysql + - MySQL-python + # The name of the PowerDNS Authoritative Server debug package default_pdns_debug_symbols_package_name: "pdns-debuginfo"