Skip to content

Commit

Permalink
Merge pull request #72 from pieterlexis/testing-fix
Browse files Browse the repository at this point in the history
Fix the tests, add 4.5 repo
  • Loading branch information
pieterlexis authored Jun 17, 2021
2 parents eaba23f + fd6e896 commit ce4ac22
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 114 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
on:
push:
pull_request:

jobs:
Tests:
name: Test role
runs-on: ubuntu-20.04
strategy:
matrix:
ansible:
- '2.9'
- '2.10'
- '2.11'
scenario:
- pdns-rec-43
- pdns-rec-44
- pdns-rec-45
- pdns-rec-master
- pdns-rec-43-no-sd-overrides
steps:
- name: checkout
uses: actions/checkout@v2
- name: Install python
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Run the tests
run: tox -- molecule test -s ${{ matrix.scenario }}
env:
ANSIBLE: ${{ matrix.ansible }}
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ansible Role: PowerDNS Recursor

[![Build Status](https://travis-ci.org/PowerDNS/pdns_recursor-ansible.svg?branch=master)](https://travis-ci.org/PowerDNS/pdns_recursor-ansible)
[![Build Status](https://github.com/PowerDNS/pdns_recursor-ansible/actions/workflows/main.yml/badge.svg)](https://github.com/PowerDNS/pdns_recursor-ansible)
[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)
[![Ansible Role](https://img.shields.io/badge/ansible%20role-PowerDNS.pdns_recursor-blue.svg)](https://galaxy.ansible.com/PowerDNS/pdns_recursor)
[![GitHub tag](https://img.shields.io/github/tag/PowerDNS/pdns_recursor-ansible.svg)](https://github.com/PowerDNS/pdns_recursor-ansible/tags)
Expand Down Expand Up @@ -43,6 +43,12 @@ By default, the PowerDNS Recursor is installed from the software repositories co
roles:
- { role: PowerDNS.pdns_recursor,
pdns_rec_install_repo: "{{ pdns_rec_powerdns_repo_44 }}" }

# Install the PowerDNS Recursor from the '4.5.x' official repository
- hosts: pdns-recursors
roles:
- { role: PowerDNS.pdns_recursor,
pdns_rec_install_repo: "{{ pdns_rec_powerdns_repo_45 }}" }
```
The examples above, show how to install the PowerDNS Recursor from the official PowerDNS repositories
Expand Down Expand Up @@ -252,7 +258,7 @@ To test all the scenarios run

To run a custom molecule command

$ tox -e py36-ansible28 -- molecule test -s pdns-rec-42
$ tox -e ansible210 -- molecule test -s pdns-rec-45

## License

Expand Down
5 changes: 1 addition & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ galaxy_info:
description: Install and configure the PowerDNS Recursor
company: PowerDNS.COM BV
license: MIT
min_ansible_version: 2.2
min_ansible_version: 2.7
platforms:
- name: EL
versions:
- 7
- 6
- 8
- name: Debian
versions:
- jessie
- stretch
- buster
- name: Ubuntu
versions:
- trusty
- bionic
- focal
- name: FreeBSD
Expand Down
3 changes: 0 additions & 3 deletions molecule/pdns-rec-44/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ dependency:
name: galaxy

platforms:
- name: centos-6
image: centos:6

- name: centos-7
image: centos:7
dockerfile_tpl: centos-systemd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
- hosts: all
vars_files:
- ../resources/vars/pdns-rec-common.yml
- ../resources/vars/pdns-rec-repo-42.yml
- ../resources/vars/pdns-rec-repo-45.yml
roles:
- { role: pdns_recursor-ansible }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

scenario:
name: pdns-rec-42
name: pdns-rec-45

driver:
name: docker
Expand All @@ -10,19 +10,20 @@ dependency:
name: galaxy

platforms:
- name: centos-6
image: centos:6

- name: centos-7
image: centos:7
dockerfile_tpl: centos-systemd

- name: centos-8
image: centos:8
dockerfile_tpl: centos-systemd

- name: ubuntu-1804
image: ubuntu:18.04
dockerfile_tpl: debian-systemd

- name: debian-9
image: debian:9
- name: ubuntu-2004
image: ubuntu:20.04
dockerfile_tpl: debian-systemd

- name: debian-10
Expand All @@ -49,6 +50,8 @@ provisioner:
create: ../resources/create.yml
destroy: ../resources/destroy.yml
prepare: ../resources/prepare.yml
# ANSIBLE0006 "systemctl used in place of systemd module"
# ANSIBLE0016 "Tasks that run when changed should likely be handlers"
lint: ansible-lint -x ANSIBLE0006 ANSIBLE0016

lint: yamllint vars tasks defaults meta
Expand All @@ -59,7 +62,6 @@ verifier:
vvv: True
directory: ../resources/tests/all
additional_files_or_dirs:
# path relative to '../resources/tests/all'
- ../repo-42/
- ../repo-45/
- ../systemd-overrides
lint: flake8
3 changes: 0 additions & 3 deletions molecule/pdns-rec-master/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ dependency:
name: galaxy

platforms:
- name: centos-6
image: centos:6

- name: centos-7
image: centos:7
dockerfile_tpl: centos-systemd
Expand Down
9 changes: 5 additions & 4 deletions molecule/resources/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
register: platforms

- name: Discover local Docker images
docker_image_facts:
docker_image_info:
name: "molecule_pdns_rec/{{ item.item.name }}"
with_items: "{{ platforms.results }}"
register: docker_images

- name: Build an Ansible compatible image
docker_image:
path: "{{ molecule_ephemeral_directory }}"
source: build
name: "molecule_pdns_rec/{{ item.item.image }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force: "{{ item.item.force | default(True) }}"
build:
path: "{{ molecule_ephemeral_directory }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
with_items: "{{ platforms.results }}"
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0

Expand Down
6 changes: 3 additions & 3 deletions molecule/resources/tests/all/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

@pytest.fixture()
def AnsibleVars(host):
varsFiles = ["../../vars/main.yml"]
varsFiles = ["vars/main.yml"]
if host.system_info.distribution.lower() in debian_os:
varsFiles.append("../../vars/Debian.yml")
varsFiles.append("vars/Debian.yml")
if host.system_info.distribution.lower() in rhel_os:
varsFiles.append("../../vars/RedHat.yml")
varsFiles.append("vars/RedHat.yml")

ansibleVars = {}
for f in varsFiles:
Expand Down
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-rec-42.list')
f = host.file('/etc/apt/sources.list.d/powerdns-rec-45.list')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-rec-42.repo')
f = host.file('/etc/yum.repos.d/powerdns-rec-45.repo')

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

assert f.exists
assert f.contains('rec-42')
assert f.contains('rec-45')


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

assert 'PowerDNS Recursor' in cmd.stderr
assert '4.2' in cmd.stderr
assert '4.5' in cmd.stderr


def systemd_override(host):
Expand Down
2 changes: 1 addition & 1 deletion molecule/resources/vars/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"
molecule_yml: "{{ lookup('file', molecule_file) | from_yaml }}"
7 changes: 0 additions & 7 deletions molecule/resources/vars/pdns-rec-repo-42.yml

This file was deleted.

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

##
# PowerDNS Recursor 4.5.x Repository
##

pdns_rec_install_repo: "{{ pdns_rec_powerdns_repo_45 }}"
10 changes: 7 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
molecule<3.1
docker-py==1.10.6
testinfra<5.4
jinja2==2.11.3
ansible-lint==5.0.7
yamllint==1.26.1
molecule[docker]==3.3.0
molecule[lint]==3.3.0
testinfra
docker==5.0.0
14 changes: 8 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
[tox]
minversion = 1.8
envlist = py{36}-ansible{27,28,29}
envlist = ansible{29,210,211}
skipsdist = true

[travis:env]
[gh-actions:env]
ANSIBLE=
2.7: ansible27
2.8: ansible28
2.9: ansible29
2.10: ansible210
2.11: ansible211

[testenv]
passenv = *
deps =
-rtest-requirements.txt
ansible27: ansible<2.8
ansible28: ansible<2.9
ansible29: ansible<2.10
ansible210: ansible<2.11
ansible211: ansible<2.12
setenv =
PY_COLORS = 1
commands =
{posargs:molecule test --all --destroy always}
18 changes: 9 additions & 9 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ pdns_rec_powerdns_repo_master:
yum_debug_symbols_repo_baseurl: "https://repo.powerdns.com/centos/$basearch/$releasever/rec-master/debug"
name: "powerdns-rec-master"

pdns_rec_powerdns_repo_42:
apt_repo_origin: "repo.powerdns.com"
apt_repo: "deb [arch=amd64] https://repo.powerdns.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release | lower }}-rec-42 main"
gpg_key: "https://repo.powerdns.com/FD380FBB-pub.asc"
gpg_key_id: "9FAAA5577E8FCF62093D036C1B0C6205FD380FBB"
yum_repo_baseurl: "https://repo.powerdns.com/centos/$basearch/$releasever/rec-42"
yum_debug_symbols_repo_baseurl: "https://repo.powerdns.com/centos/$basearch/$releasever/rec-42/debug"
name: "powerdns-rec-42"

pdns_rec_powerdns_repo_43:
apt_repo_origin: "repo.powerdns.com"
apt_repo: "deb [arch=amd64] https://repo.powerdns.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release | lower }}-rec-43 main"
Expand All @@ -38,6 +29,15 @@ pdns_rec_powerdns_repo_44:
yum_debug_symbols_repo_baseurl: "https://repo.powerdns.com/centos/$basearch/$releasever/rec-44/debug"
name: "powerdns-rec-44"

pdns_rec_powerdns_repo_45:
apt_repo_origin: "repo.powerdns.com"
apt_repo: "deb [arch=amd64] https://repo.powerdns.com/{{ ansible_distribution | lower }} {{ ansible_distribution_release | lower }}-rec-45 main"
gpg_key: "https://repo.powerdns.com/FD380FBB-pub.asc"
gpg_key_id: "9FAAA5577E8FCF62093D036C1B0C6205FD380FBB"
yum_repo_baseurl: "https://repo.powerdns.com/centos/$basearch/$releasever/rec-45"
yum_debug_symbols_repo_baseurl: "https://repo.powerdns.com/centos/$basearch/$releasever/rec-45/debug"
name: "powerdns-rec-45"

default_pdns_rec_service_overrides: >-
{{ { 'User' : pdns_rec_user
, 'Group' : pdns_rec_group
Expand Down

0 comments on commit ce4ac22

Please sign in to comment.