Skip to content

Commit

Permalink
Add support to the Auth 4.3. Install missing SQLite packages. Improve…
Browse files Browse the repository at this point in the history
…d files and dirs permissions. (#69)
  • Loading branch information
atosatto committed Dec 11, 2019
1 parent 264a3d8 commit 7a42374
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 143 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Ansible ###
*.retry
.ansible_cache

### Python ###
# Byte-compiled / optimized / DLL files
Expand Down
20 changes: 13 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
---
language: python
python: 2.7
python:
- "2.7"
- "3.6"

sudo: required

# Enable the docker service
services:
- docker

# Replace aufs with the vfs docker storage driver
# to prevent systemd to fail starting docker in docker.
before_install:
- sudo sed -i 's|DOCKER_OPTS=.*|DOCKER_OPTS="-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock --storage-driver vfs"|g' /etc/default/docker
- sudo service docker restart
- docker info

# Parallel testing of the supported
# Ansible versions
env:
matrix:
- ANSIBLE=2.2
- ANSIBLE=2.3
- ANSIBLE=2.4
- ANSIBLE=2.5
- ANSIBLE=2.6
- ANSIBLE=2.7
- ANSIBLE=2.8
- ANSIBLE=2.9

# Install tox
install:
- pip install tox-travis

# Test the current PowerDNS Authoritative Server stable release
script:
- tox -- molecule test -s pdns-41
- tox -- molecule test -s pdns-42

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ To test all the scenarios run

To run a custom molecule command

$ tox -e py27-ansible22 -- molecule test -s pdns-41
$ tox -e py27-ansible22 -- molecule test -s pdns-42

## License

Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ galaxy_info:
- dns
- pdns
- powerdns
- pdns-auth
- auth

dependencies: []
57 changes: 35 additions & 22 deletions molecule/pdns-41/molecule.yml → molecule/pdns-42/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

scenario:
name: pdns-41
name: pdns-42

driver:
name: docker
Expand All @@ -11,38 +11,35 @@ dependency:

platforms:
- name: centos-6
groups: ["pdns"]
image: centos:6
groups:
- pdns

- name: centos-7
groups: ["pdns"]
image: centos:7
dockerfile_tpl: centos-systemd
groups:
- pdns

- name: ubuntu-1604
image: ubuntu:16.04
dockerfile_tpl: debian-systemd
groups:
- pdns
# 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
groups:
- pdns

- name: debian-8
image: debian:8
groups:
- pdns

- name: debian-9
groups: ["pdns"]
image: debian:9
dockerfile_tpl: debian-systemd
groups:
- pdns

- 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
Expand All @@ -60,15 +57,31 @@ provisioner:
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
lint:
name: ansible-lint
options:
# excludes "systemctl used in place of systemd module"
x: ["ANSIBLE0006"]
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:
name: yamllint
Expand All @@ -81,7 +94,7 @@ verifier:
directory: ../resources/tests/all
additional_files_or_dirs:
# path relative to 'directory'
- ../repo-41/
- ../repo-42/
- ../backend-sqlite/
- ../backend-mysql/
lint:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- hosts: pdns
vars_files:
- ../resources/vars/pdns-common.yml
- ../resources/vars/pdns-repo-41.yml
- ../resources/vars/pdns-repo-42.yml
- ../resources/vars/pdns-backends.yml
roles:
- { role: pdns-ansible }
53 changes: 33 additions & 20 deletions molecule/pdns-master/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,35 @@ dependency:

platforms:
- name: centos-6
groups: ["pdns"]
image: centos:6
groups:
- pdns

- name: centos-7
groups: ["pdns"]
image: centos:7
dockerfile_tpl: centos-systemd
groups:
- pdns

- name: ubuntu-1604
image: ubuntu:16.04
dockerfile_tpl: debian-systemd
groups:
- pdns
# 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
groups:
- pdns

- name: debian-8
image: debian:8
groups:
- pdns

- name: debian-9
groups: ["pdns"]
image: debian:9
dockerfile_tpl: debian-systemd
groups:
- pdns

- 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
Expand All @@ -60,15 +57,31 @@ provisioner:
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
lint:
name: ansible-lint
options:
# excludes "systemctl used in place of systemd module"
x: ["ANSIBLE0006"]
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:
name: yamllint
Expand Down
3 changes: 2 additions & 1 deletion molecule/resources/Dockerfile.centos-systemd.j2
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ VOLUME [ "/sys/fs/cgroup" ]

CMD ["/usr/sbin/init"]

RUN if [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python python-devel python2-dnf net-tools bash && dnf clean all; \
RUN if [ $(command -v dnf) ] && [ $(rpm -E %{rhel}) -eq 8 ]; then dnf makecache && dnf --assumeyes install python3 python3-devel python*-dnf bash iproute && dnf clean all; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash iproute && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl net-tools bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; fi
3 changes: 3 additions & 0 deletions molecule/resources/host_vars/centos-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

ansible_python_interpreter: "/usr/bin/python3"
2 changes: 1 addition & 1 deletion molecule/resources/tests/all/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def systemd_override(host):
assert f.exists
assert f.user == 'root'
assert f.group == 'root'
assert 'LimitCORE=infinity' in f.content
assert f.contains('LimitCORE=infinity')
22 changes: 9 additions & 13 deletions molecule/resources/tests/backend-mysql/test_backend_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,20 @@ def test_config(host):
dbname = host.check_output('hostname -s').replace('.', '_')

assert f.exists
assert 'launch+=gmysql' in f.content
assert 'gmysql-host=mysql' in f.content
assert 'gmysql-password=pdns' in f.content
assert 'gmysql-dbname=' + dbname in f.content
assert 'gmysql-user=pdns' in f.content
assert f.contains('launch+=gmysql')
assert f.contains('gmysql-host=mysql')
assert f.contains('gmysql-password=pdns')
assert f.contains('gmysql-dbname=' + dbname)
assert f.contains('gmysql-user=pdns')


def test_database_tables(host):
dbname = host.check_output('hostname -s').replace('.', '_')

cmd = host.run("mysql --user=\"pdns\" --password=\"pdns\" --host=\"mysql\" " +
cmd = host.run("mysql --user=\"pdns\" --password=\"pdns\" --host=\"mysql\" " +
"--batch --skip-column-names " +
"--execute=\"SELECT DISTINCT table_name FROM information_schema.columns WHERE table_schema = '%s'\"" % dbname)

assert 'domains' in cmd.stdout
assert 'records' in cmd.stdout
assert 'supermasters' in cmd.stdout
assert 'comments' in cmd.stdout
assert 'domainmetadata' in cmd.stdout
assert 'cryptokeys' in cmd.stdout
assert 'tsigkeys' in cmd.stdout
for table in [ 'domains', 'records', 'supermasters', 'comments',
'domainmetadata', 'cryptokeys', 'tsigkeys' ]:
assert table in cmd.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ def test_database_exists(host):
assert f.exists
assert f.user == 'pdns'
assert f.group == 'pdns'
assert f.mode == 416
assert f.mode == 0o640
assert f.size > 10000
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
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-41.list')
f = host.file('/etc/apt/sources.list.d/powerdns-auth-42.list')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-auth-41.repo')
f = host.file('/etc/yum.repos.d/powerdns-auth-42.repo')

assert f.exists
assert f.user == 'root'
Expand All @@ -18,15 +18,16 @@ def test_repo_file(host):
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-41.list')
f = host.file('/etc/apt/sources.list.d/powerdns-auth-42.list')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-auth-41.repo')
f = host.file('/etc/yum.repos.d/powerdns-auth-42.repo')

assert f.exists
assert f.contains('auth-41')
assert f.contains('auth-42')


def test_pdns_version(host):
cmd = host.run('/usr/sbin/pdns_server --version')

assert 'PowerDNS Authoritative Server 4.1.' in cmd.stderr
assert 'PowerDNS Authoritative Server' in cmd.stderr
assert '4.2' in cmd.stderr
3 changes: 2 additions & 1 deletion molecule/resources/tests/repo-master/test_repo_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ def test_pdns_repo(host):
def test_pdns_version(host):
cmd = host.run('/usr/sbin/pdns_server --version')

assert 'PowerDNS Authoritative Server 0.0.' in cmd.stderr
assert 'PowerDNS Authoritative Server' in cmd.stderr
assert 'master' in cmd.stderr
7 changes: 0 additions & 7 deletions molecule/resources/vars/pdns-repo-41.yml

This file was deleted.

7 changes: 7 additions & 0 deletions molecule/resources/vars/pdns-repo-42.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

##
# PowerDNS 4.2.x Repository
##

pdns_install_repo: "{{ pdns_auth_powerdns_repo_42 }}"
Loading

0 comments on commit 7a42374

Please sign in to comment.