Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v1.7.3 (Unreleased)

IMPROVEMENTS:
- Rework apt and dnf repo file creation to stop using version suffixed file names which are not cleaned up on version changes ([\#183](https://github.com/PowerDNS/dnsdist-ansible/pull/183), @l00d3r)
- Remove version suffixed apt and dnf repo files ([\#183](https://github.com/PowerDNS/dnsdist-ansible/pull/183), @l00d3r)

## v1.7.2 (2026-02-23)

BUG FIXES:
Expand Down
12 changes: 12 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,15 @@ dnsdist_tlslocals: []
# - Force a downgrade
# - Automation of test scenario's where switching between versions on the same server is necessary
dnsdist_force_reinstall: false

# Name of installable repo
dnsdist_install_repo_name: powerdns-dnsdist

# Regex for matching and removing non-version suffixed repos
dnsdist_install_repo_regex: "{{ '^' + dnsdist_install_repo_name + '\\.(list|sources|repo|asc)$' }}"

# Regex for matching and removing version suffixed repos
dnsdist_remove_versioned_repo_regex: '^powerdns-dnsdist-(master|\d+)\.(list|sources|repo|asc)$'
Comment thread
l00d3r marked this conversation as resolved.

# When set to true remove version suffixed repos, set to false to keep using version suffixed repos
dnsdist_remove_versioned_repo_files: true
10 changes: 5 additions & 5 deletions molecule/resources/tests/repo-19/test_repo_19.py
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-dnsdist-19.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-dnsdist-19.repo')
f = host.file('/etc/yum.repos.d/powerdns-dnsdist.repo')

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

assert f.exists
assert f.contains('dnsdist-19')


def test_pdns_repo_architecture(host):
if host.system_info.distribution.lower() in debian_os:
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist-19.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
apt_arch = host.check_output('dpkg --print-architecture').strip()

assert f.contains(f'Architectures: {apt_arch}')
Expand Down
10 changes: 5 additions & 5 deletions molecule/resources/tests/repo-20/test_repo_20.py
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-dnsdist-20.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-dnsdist-20.repo')
f = host.file('/etc/yum.repos.d/powerdns-dnsdist.repo')

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

assert f.exists
assert f.contains('dnsdist-20')


def test_pdns_repo_architecture(host):
if host.system_info.distribution.lower() in debian_os:
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist-20.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
apt_arch = host.check_output('dpkg --print-architecture').strip()

assert f.contains(f'Architectures: {apt_arch}')
Expand Down
10 changes: 5 additions & 5 deletions molecule/resources/tests/repo-21/test_repo_21.py
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-dnsdist-21.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-dnsdist-21.repo')
f = host.file('/etc/yum.repos.d/powerdns-dnsdist.repo')

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

assert f.exists
assert f.contains('dnsdist-21')


def test_pdns_repo_architecture(host):
if host.system_info.distribution.lower() in debian_os:
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist-21.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
apt_arch = host.check_output('dpkg --print-architecture').strip()

assert f.contains(f'Architectures: {apt_arch}')
Expand Down
8 changes: 4 additions & 4 deletions molecule/resources/tests/repo-master/test_repo_master.py
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-dnsdist-master.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-dnsdist-master.repo')
f = host.file('/etc/yum.repos.d/powerdns-dnsdist.repo')

assert f.exists
assert f.user == 'root'
Expand All @@ -18,9 +18,9 @@ def test_repo_file(host):
def test_dnsdist_repo(host):
f = None
if host.system_info.distribution.lower() in debian_os:
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist-master.sources')
f = host.file('/etc/apt/sources.list.d/powerdns-dnsdist.sources')
if host.system_info.distribution.lower() in rhel_os:
f = host.file('/etc/yum.repos.d/powerdns-dnsdist-master.repo')
f = host.file('/etc/yum.repos.d/powerdns-dnsdist.repo')

assert f.exists
assert f.contains('dnsdist-master')
Expand Down
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
tags:
- always

- name: Set fact for repo name
when: "dnsdist_install_repo | length > 0"
ansible.builtin.set_fact:
dnsdist_repo_name: "{{ dnsdist_remove_versioned_repo_files | ternary(dnsdist_install_repo_name, dnsdist_install_repo['name']) }}"
dnsdist_repo_regex: "{{ dnsdist_remove_versioned_repo_files | ternary(dnsdist_remove_versioned_repo_regex, dnsdist_install_repo_regex) }}"
Comment thread
l00d3r marked this conversation as resolved.
tags:
- install
- repository

- name: Setup repository
ansible.builtin.include_tasks: "repo-{{ ansible_os_family }}.yml"
when: dnsdist_install_repo | length > 0
Expand Down
24 changes: 23 additions & 1 deletion tasks/repo-Debian.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
---
- name: Find repo and key files matching dnsdist_repo_regex
ansible.builtin.find:
paths:
- /etc/apt/sources.list.d/
- /etc/apt/trusted.gpg.d/
- /etc/apt/keyrings/
patterns: "{{ dnsdist_repo_regex }}"
use_regex: true
register: _dnsdist_version_suffixed_repo_files
tags:
- install
- repository

Comment on lines 1 to +14

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ansible.builtin.find will not fail if a path does not exist, it emits a warning

- name: Remove found matching repo and key files
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ _dnsdist_version_suffixed_repo_files.files | map(attribute='path') | list }}"
tags:
- install
- repository

- name: Install python3-debian (required by deb822_repository)
ansible.builtin.package:
name: python3-debian
state: present

- name: Add the dnsdist APT Repository (Deb822-style)
ansible.builtin.deb822_repository:
name: "{{ dnsdist_install_repo['name'] }}"
name: "{{ dnsdist_repo_name }}"
types: deb
uris: "http://{{ dnsdist_install_repo['apt_repo_origin'] }}/{{ ansible_distribution | lower }}/"
suites: "{{ ansible_distribution_release | lower }}-{{ dnsdist_install_repo['apt_version'] }}"
Expand Down
27 changes: 23 additions & 4 deletions tasks/repo-RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
---
- name: Find repo files matching dnsdist_repo_regex
ansible.builtin.find:
paths: /etc/yum.repos.d/
patterns: "{{ dnsdist_repo_regex }}"
use_regex: true
register: _dnsdist_version_suffixed_repo_files
tags:
- install
- repository

- name: Remove found matching repo and key files
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop: "{{ _dnsdist_version_suffixed_repo_files.files | map(attribute='path') | list }}"
tags:
- install
- repository

- name: Set up EPEL
when: dnsdist_install_epel
block:
Expand Down Expand Up @@ -32,8 +51,8 @@

- name: Add the dnsdist YUM Repository
ansible.builtin.yum_repository:
name: "{{ dnsdist_install_repo['name'] }}"
file: "{{ dnsdist_install_repo['name'] }}"
name: "{{ dnsdist_repo_name }}"
file: "{{ dnsdist_repo_name }}"
description: PowerDNS dnsdist Repository
baseurl: "{{ dnsdist_install_repo['yum_repo_baseurl'] }}"
gpgkey: "{{ dnsdist_install_repo['gpg_key_url'] }}"
Expand All @@ -43,8 +62,8 @@

- name: Add the dnsdist debug symbols YUM Repository
ansible.builtin.yum_repository:
name: "{{ dnsdist_install_repo['name'] }}-debuginfo"
file: "{{ dnsdist_install_repo['name'] }}"
name: "{{ dnsdist_repo_name }}-debuginfo"
file: "{{ dnsdist_repo_name }}"
description: PowerDNS dnsdist Repository - debug symbols
baseurl: "{{ dnsdist_install_repo['yum_debug_symbols_repo_baseurl'] }}"
gpgkey: "{{ dnsdist_install_repo['gpg_key_url'] }}"
Expand Down
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _dnsdist_arch_map_debian:
aarch64: arm64
arm64: arm64
armv8l: arm64
_dnsdist_apt_architecture: "{{ _dnsdist_arch_map_debian.get(ansible_architecture | lower, 'amd64' ) }}"
_dnsdist_apt_architecture: "{{ _dnsdist_arch_map_debian.get(ansible_architecture | lower, 'amd64') }}"

dnsdist_powerdns_repo_master:
apt_repo_origin: repo.powerdns.com
Expand Down