diff --git a/.travis.yml b/.travis.yml index 638ae2b..51c524d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,10 @@ --- +os: linux +dist: focal language: python python: - - "2.7" - "3.6" -sudo: required - # Enable the docker service services: - docker @@ -20,10 +19,22 @@ before_install: # Parallel testing of the supported # Ansible versions env: - matrix: - - ANSIBLE=2.7 - - ANSIBLE=2.8 - - ANSIBLE=2.9 + jobs: + - ANSIBLE=2.7 AUTH_VERSION=42 + - ANSIBLE=2.7 AUTH_VERSION=43 + - ANSIBLE=2.7 AUTH_VERSION=master + + - ANSIBLE=2.8 AUTH_VERSION=42 + - ANSIBLE=2.8 AUTH_VERSION=43 + - ANSIBLE=2.8 AUTH_VERSION=master + + - ANSIBLE=2.9 AUTH_VERSION=42 + - ANSIBLE=2.9 AUTH_VERSION=43 + - ANSIBLE=2.9 AUTH_VERSION=master + +jobs: + allow_failures: + - env: REC_VERSION=master # Install tox install: @@ -31,7 +42,7 @@ install: # Test the current PowerDNS Authoritative Server stable release script: - - tox -- molecule test -s pdns-42 + - tox -- molecule test -s pdns-${AUTH_VERSION} notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/meta/main.yml b/meta/main.yml index 317c1df..1779509 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -15,14 +15,12 @@ galaxy_info: versions: - jessie - stretch + - buster - name: Ubuntu versions: - - trusty - - utopic - - vivid - - wily - xenial - bionic + - focal galaxy_tags: - system - dns diff --git a/molecule/pdns-42/playbook.yml b/molecule/pdns-42/converge.yml similarity index 100% rename from molecule/pdns-42/playbook.yml rename to molecule/pdns-42/converge.yml diff --git a/molecule/pdns-42/molecule.yml b/molecule/pdns-42/molecule.yml index ca527df..8d1ddab 100644 --- a/molecule/pdns-42/molecule.yml +++ b/molecule/pdns-42/molecule.yml @@ -72,19 +72,12 @@ provisioner: create: ../resources/create.yml destroy: ../resources/destroy.yml prepare: ../resources/prepare.yml - lint: - name: ansible-lint - options: - x: - # "systemctl used in place of systemd module" - - "ANSIBLE0006" - # "Tasks that run when changed should likely be handlers" - - "ANSIBLE0016" - # "Shells that use pipes should set the pipefail option" - - "306" + # "systemctl used in place of systemd module" "ANSIBLE0006" + # "Tasks that run when changed should likely be handlers" "ANSIBLE0016" + # "Shells that use pipes should set the pipefail option" "306" + lint: ansible-lint -x ANSIBLE0006 ANSIBLE0016 306 -lint: - name: yamllint +lint: yamllint defaults tasks meta vars verifier: name: testinfra @@ -97,5 +90,4 @@ verifier: - ../repo-42/ - ../backend-sqlite/ - ../backend-mysql/ - lint: - name: flake8 + lint: flake8 diff --git a/molecule/pdns-43/converge.yml b/molecule/pdns-43/converge.yml new file mode 100644 index 0000000..5012f0a --- /dev/null +++ b/molecule/pdns-43/converge.yml @@ -0,0 +1,9 @@ +--- + +- hosts: pdns + vars_files: + - ../resources/vars/pdns-common.yml + - ../resources/vars/pdns-repo-43.yml + - ../resources/vars/pdns-backends.yml + roles: + - { role: pdns-ansible } diff --git a/molecule/pdns-43/molecule.yml b/molecule/pdns-43/molecule.yml new file mode 100644 index 0000000..f058e06 --- /dev/null +++ b/molecule/pdns-43/molecule.yml @@ -0,0 +1,93 @@ +--- + +scenario: + name: pdns-43 + +driver: + name: docker + +dependency: + name: galaxy + +platforms: + - name: centos-6 + groups: ["pdns"] + image: centos:6 + + - name: centos-7 + groups: ["pdns"] + 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: ubuntu-1804 + groups: ["pdns"] + image: ubuntu:18.04 + dockerfile_tpl: debian-systemd + + - name: debian-9 + groups: ["pdns"] + image: debian:9 + dockerfile_tpl: debian-systemd + + - name: debian-10 + groups: ["pdns"] + image: debian:10 + dockerfile_tpl: debian-systemd + + # In order to run the tests we need + # a MySQL container to be up & running + - name: mysql + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: pdns + # Declaring the container as service, + # will link it to the others Platforms containers + # on creation. + is_service: yes + +provisioner: + name: ansible + options: + diff: True + v: True + config_options: + defaults: + gathering: smart + fact_caching: jsonfile + fact_caching_connection: .ansible_cache + fact_caching_timeout: 7200 + ssh_connection: + pipelining: true + inventory: + links: + host_vars: ../resources/host_vars/ + playbooks: + create: ../resources/create.yml + destroy: ../resources/destroy.yml + prepare: ../resources/prepare.yml + # "systemctl used in place of systemd module" "ANSIBLE0006" + # "Tasks that run when changed should likely be handlers" "ANSIBLE0016" + # "Shells that use pipes should set the pipefail option" "306" + lint: ansible-lint -x ANSIBLE0006 ANSIBLE0016 306 + +lint: yamllint defaults tasks meta vars + +verifier: + name: testinfra + options: + hosts: "pdns" + vvv: True + directory: ../resources/tests/all + additional_files_or_dirs: + # path relative to 'directory' + - ../repo-43/ + - ../backend-sqlite/ + - ../backend-mysql/ + lint: flake8 diff --git a/molecule/pdns-master/playbook.yml b/molecule/pdns-master/converge.yml similarity index 100% rename from molecule/pdns-master/playbook.yml rename to molecule/pdns-master/converge.yml diff --git a/molecule/pdns-master/molecule.yml b/molecule/pdns-master/molecule.yml index 0c4302f..6fa920f 100644 --- a/molecule/pdns-master/molecule.yml +++ b/molecule/pdns-master/molecule.yml @@ -72,19 +72,9 @@ provisioner: create: ../resources/create.yml destroy: ../resources/destroy.yml prepare: ../resources/prepare.yml - lint: - name: ansible-lint - options: - x: - # "systemctl used in place of systemd module" - - "ANSIBLE0006" - # "Tasks that run when changed should likely be handlers" - - "ANSIBLE0016" - # "Shells that use pipes should set the pipefail option" - - "306" + lint: ansible-lint -x ANSIBLE0006 ANSIBLE0016 306 -lint: - name: yamllint +lint: yamllint defaults tasks meta vars verifier: name: testinfra @@ -97,5 +87,4 @@ verifier: - ../repo-master/ - ../backend-sqlite/ - ../backend-mysql/ - lint: - name: flake8 + lint: flake8 diff --git a/molecule/resources/tests/repo-43/test_repo_43.py b/molecule/resources/tests/repo-43/test_repo_43.py new file mode 100644 index 0000000..2c915bf --- /dev/null +++ b/molecule/resources/tests/repo-43/test_repo_43.py @@ -0,0 +1,33 @@ + +debian_os = ['debian', 'ubuntu'] +rhel_os = ['redhat', 'centos'] + + +def test_repo_file(host): + f = None + if host.system_info.distribution.lower() in debian_os: + f = host.file('/etc/apt/sources.list.d/powerdns-auth-43.list') + if host.system_info.distribution.lower() in rhel_os: + f = host.file('/etc/yum.repos.d/powerdns-auth-43.repo') + + assert f.exists + assert f.user == 'root' + assert f.group == 'root' + + +def test_pdns_repo(host): + f = None + if host.system_info.distribution.lower() in debian_os: + f = host.file('/etc/apt/sources.list.d/powerdns-auth-43.list') + if host.system_info.distribution.lower() in rhel_os: + f = host.file('/etc/yum.repos.d/powerdns-auth-43.repo') + + assert f.exists + assert f.contains('auth-43') + + +def test_pdns_version(host): + cmd = host.run('/usr/sbin/pdns_server --version') + + assert 'PowerDNS Authoritative Server' in cmd.stderr + assert '4.3' in cmd.stderr diff --git a/molecule/resources/vars/pdns-repo-43.yml b/molecule/resources/vars/pdns-repo-43.yml new file mode 100644 index 0000000..8518de4 --- /dev/null +++ b/molecule/resources/vars/pdns-repo-43.yml @@ -0,0 +1,7 @@ +--- + +## +# PowerDNS 4.3.x Repository +## + +pdns_install_repo: "{{ pdns_auth_powerdns_repo_43 }}" diff --git a/tasks/database-mysql.yml b/tasks/database-mysql.yml index 3cdd4bb..7f9d91f 100644 --- a/tasks/database-mysql.yml +++ b/tasks/database-mysql.yml @@ -13,6 +13,7 @@ name: - default-mysql-client - python-mysqldb + - python3-mysqldb state: present when: ansible_os_family == 'Debian' diff --git a/test-requirements.txt b/test-requirements.txt index 8b7999f..f932207 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,3 @@ -molecule==2.22.0 +molecule<3.1 docker-py==1.10.6 +testinfra<5.4 diff --git a/tox.ini b/tox.ini index 1f0a3c5..839f6c0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 1.8 -envlist = py{27,36}-ansible{27,28,29} +envlist = py36-ansible{27,28,29} skipsdist = true [travis:env]