summaryrefslogtreecommitdiffstats
path: root/distro/tests/knot-dns-test.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'distro/tests/knot-dns-test.yaml')
-rw-r--r--distro/tests/knot-dns-test.yaml158
1 files changed, 158 insertions, 0 deletions
diff --git a/distro/tests/knot-dns-test.yaml b/distro/tests/knot-dns-test.yaml
new file mode 100644
index 0000000..828f71e
--- /dev/null
+++ b/distro/tests/knot-dns-test.yaml
@@ -0,0 +1,158 @@
+---
+- hosts: all
+
+ remote_user: root
+ become: true
+
+ vars:
+ dig_package:
+ Debian: dnsutils
+ Ubuntu: dnsutils
+ Fedora: bind-utils
+ CentOS: bind-utils
+ openSUSE Leap: bind-utils
+ openSUSE Tumbleweed: bind-utils
+ Archlinux: bind-tools
+ configure_obs_repo:
+ Fedora: |
+ dnf config-manager --add-repo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/Fedora_{{ ansible_distribution_major_version }}/home:CZ-NIC:{{ item }}.repo
+ CentOS: |
+ yum install -y wget &&
+ wget -i wget https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/CentOS_7_EPEL/home:CZ-NIC:{{ item }}.repo -O /etc/yum.repos.d/home:CZ-NIC:{{ item }}.repo
+ Debian: |
+ echo 'deb http://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/Debian_9.0/ /' > /etc/apt/sources.list.d/{{ item }}.list &&
+ wget -nv https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/Debian_9.0/Release.key -O Release.key &&
+ apt-key add - < Release.key &&
+ apt-get update
+ Ubuntu: |
+ echo 'deb http://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/xUbuntu_{{ ansible_distribution_version }}/ /' > /etc/apt/sources.list.d/{{ item }}.list &&
+ wget -nv https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/xUbuntu_{{ ansible_distribution_version }}/Release.key -O Release.key &&
+ apt-key add - < Release.key &&
+ apt-get update
+ openSUSE Tumbleweed: |
+ zypper addrepo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/openSUSE_Tumbleweed/home:CZ-NIC:{{ item }}.repo &&
+ zypper --gpg-auto-import-keys refresh
+ openSUSE Leap: |
+ zypper addrepo https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/openSUSE_Leap_15.0/home:CZ-NIC:{{ item }}.repo &&
+ zypper --gpg-auto-import-keys refresh
+ show_package_version:
+ Archlinux:
+ pacman -Qi knot | grep '^Version'
+ Fedora: &pkg_version_rpm |
+ rpm -qi knot | grep '^Version'
+ CentOS: *pkg_version_rpm
+ openSUSE Leap: *pkg_version_rpm
+ openSUSE Tumbleweed: *pkg_version_rpm
+ Debian: &pkg_version_dpkg |
+ dpkg -s knot | grep '^Version'
+ Ubuntu: *pkg_version_dpkg
+ vars_files:
+ - repos.yaml
+
+ gather_facts: false
+ pre_tasks:
+ - name: install python3 (Arch)
+ raw: |
+ (pacman-key --init && pacman-key --populate archlinux && \
+ pacman -Sy python3 --noconfirm) || :
+ ignore_errors: true
+ - name: gather facts
+ setup:
+
+ tasks:
+ - name: install epel
+ package:
+ name: epel-release
+ state: present
+ when: ansible_distribution == 'CentOS'
+
+ - name: configure OBS repository
+ shell: "{{ configure_obs_repo[ansible_distribution] }}"
+ args:
+ warn: false
+ with_items: "{{ repos }}"
+ when: ansible_distribution_file_variety != 'Archlinux'
+
+ - block:
+ - name: configure OBS repository (Arch)
+ blockinfile:
+ block: |
+ [home_CZ-NIC_{{ item }}_Arch]
+ SigLevel = Never
+ Server = https://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/Arch/$arch
+ insertbefore: '^\[core\]'
+ path: /etc/pacman.conf
+ state: present
+ with_items: "{{ repos }}"
+ - name: sync repos (Arch)
+ shell: pacman -Syu --noconfirm
+ args:
+ warn: false
+ when: ansible_distribution_file_variety == 'Archlinux'
+
+ - name: install knot
+ package:
+ name: knot
+ state: latest
+
+ - name: get installed package version
+ shell: "{{ show_package_version[ansible_distribution] }}"
+ args:
+ warn: false
+ register: package_version
+
+ - name: install dig
+ package:
+ name: "{{ dig_package[ansible_distribution] }}"
+ state: present
+
+
+ - name: testing block
+ block:
+ - name: create example.com zone
+ copy:
+ dest: /etc/knot/example.com.zone
+ content: |
+ $ORIGIN example.com.
+ $TTL 3600
+ @ SOA dns1.example.com. hostmaster.example.com. (
+ 2010111213 ; serial
+ 6h ; refresh
+ 1h ; retry
+ 1w ; expire
+ 1d ) ; minimum
+ NS dns1
+ dns1 A 192.0.2.1
+
+ - name: create config
+ blockinfile:
+ dest: /etc/knot/knot.conf
+ block: |
+ zone:
+ - domain: example.com
+ file: "/etc/knot/example.com.zone"
+
+ - name: start knot.service
+ service:
+ name: knot.service
+ state: restarted
+
+ - name: resolve dns1.example.com
+ shell: dig @127.0.0.1 dns1.example.com A
+ register: res
+ failed_when: '"192.0.2.1" not in res.stdout'
+
+ - name: reload knot.service
+ service:
+ name: knot.service
+ state: reloaded
+
+ - name: resolve dns1.example.com
+ shell: dig @127.0.0.1 dns1.example.com A
+ register: res
+ failed_when: '"192.0.2.1" not in res.stdout'
+
+ always:
+ - name: show installed version
+ debug:
+ var: package_version.stdout