summaryrefslogtreecommitdiffstats
path: root/distro/tests/ansible-roles
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--distro/tests/ansible-roles/knot_dns/defaults/main.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/tasks/configure_zone.yaml24
-rw-r--r--distro/tests/ansible-roles/knot_dns/tasks/main.yaml40
-rw-r--r--distro/tests/ansible-roles/knot_dns/tasks/reload_knot.yaml15
-rw-r--r--distro/tests/ansible-roles/knot_dns/tasks/restart_knot.yaml15
-rw-r--r--distro/tests/ansible-roles/knot_dns/tasks/test_tcp.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/tasks/test_udp.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/vars/CentOS.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/vars/Debian.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/vars/Fedora.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/vars/Ubuntu.yaml5
-rw-r--r--distro/tests/ansible-roles/knot_dns/vars/openSUSE_Leap.yaml5
-rw-r--r--distro/tests/ansible-roles/obs_repos/defaults/main.yaml3
-rw-r--r--distro/tests/ansible-roles/obs_repos/tasks/CentOS.yaml12
-rw-r--r--distro/tests/ansible-roles/obs_repos/tasks/Debian.yaml14
-rw-r--r--distro/tests/ansible-roles/obs_repos/tasks/Fedora.yaml7
-rw-r--r--distro/tests/ansible-roles/obs_repos/tasks/Ubuntu.yaml13
-rw-r--r--distro/tests/ansible-roles/obs_repos/tasks/main.yaml11
-rw-r--r--distro/tests/ansible-roles/obs_repos/tasks/openSUSE_Leap.yaml17
-rw-r--r--distro/tests/ansible-roles/obs_repos/vars/CentOS.yaml2
-rw-r--r--distro/tests/ansible-roles/obs_repos/vars/Debian_10.yaml2
-rw-r--r--distro/tests/ansible-roles/obs_repos/vars/Debian_9.yaml2
-rw-r--r--distro/tests/ansible-roles/obs_repos/vars/Fedora.yaml2
-rw-r--r--distro/tests/ansible-roles/obs_repos/vars/Ubuntu.yaml2
-rw-r--r--distro/tests/ansible-roles/obs_repos/vars/openSUSE_Leap.yaml2
25 files changed, 223 insertions, 0 deletions
diff --git a/distro/tests/ansible-roles/knot_dns/defaults/main.yaml b/distro/tests/ansible-roles/knot_dns/defaults/main.yaml
new file mode 100644
index 0000000..0beb2ed
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/defaults/main.yaml
@@ -0,0 +1,5 @@
+---
+repos:
+ - knot-dns-latest
+update_packages: false
+distro: "{{ ansible_distribution | replace(' ', '_') }}"
diff --git a/distro/tests/ansible-roles/knot_dns/tasks/configure_zone.yaml b/distro/tests/ansible-roles/knot_dns/tasks/configure_zone.yaml
new file mode 100644
index 0000000..c6cce01
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/tasks/configure_zone.yaml
@@ -0,0 +1,24 @@
+---
+- name: create example.com zone
+ copy:
+ dest: /etc/knot/example.com.zone
+ mode: 0644
+ 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"
diff --git a/distro/tests/ansible-roles/knot_dns/tasks/main.yaml b/distro/tests/ansible-roles/knot_dns/tasks/main.yaml
new file mode 100644
index 0000000..ccaa671
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/tasks/main.yaml
@@ -0,0 +1,40 @@
+---
+- name: Include distribution specific vars
+ include_vars: "{{ distro }}.yaml"
+
+- name: Update all packages
+ package:
+ name: '*'
+ state: latest
+ when: update_packages|bool
+
+- name: Install packages
+ package:
+ name: "{{ packages }}"
+ state: latest
+
+- name: Always print package version at the end
+ block:
+
+ - include: configure_zone.yaml
+ - include: restart_knot.yaml
+
+ - include: test_udp.yaml
+ - include: test_tcp.yaml
+
+ - include: reload_knot.yaml
+
+ - include: test_udp.yaml
+ - include: test_tcp.yaml
+
+ always:
+
+ - name: Get installed package version
+ shell: "{{ show_package_version }}"
+ args:
+ warn: false
+ register: package_version
+
+ - name: Show installed version
+ debug:
+ var: package_version.stdout
diff --git a/distro/tests/ansible-roles/knot_dns/tasks/reload_knot.yaml b/distro/tests/ansible-roles/knot_dns/tasks/reload_knot.yaml
new file mode 100644
index 0000000..b7e681c
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/tasks/reload_knot.yaml
@@ -0,0 +1,15 @@
+---
+- block:
+ - name: Reload knot.service
+ service:
+ name: knot.service
+ state: reloaded
+ rescue:
+ - name: Get knot.service journal
+ shell: journalctl -u knot --since -20s
+ register: journal
+ - name: Print journal
+ debug:
+ var: journal
+ - name: Reload knot.service failed, see log above
+ shell: /bin/false
diff --git a/distro/tests/ansible-roles/knot_dns/tasks/restart_knot.yaml b/distro/tests/ansible-roles/knot_dns/tasks/restart_knot.yaml
new file mode 100644
index 0000000..08a3752
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/tasks/restart_knot.yaml
@@ -0,0 +1,15 @@
+---
+- block:
+ - name: Restart knot.service
+ service:
+ name: knot.service
+ state: restarted
+ rescue:
+ - name: Get knot.service journal
+ shell: journalctl -u knot --since -20s
+ register: journal
+ - name: Print journal
+ debug:
+ var: journal
+ - name: Restart knot.service failed, see log above
+ shell: /bin/false
diff --git a/distro/tests/ansible-roles/knot_dns/tasks/test_tcp.yaml b/distro/tests/ansible-roles/knot_dns/tasks/test_tcp.yaml
new file mode 100644
index 0000000..68dd8e9
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/tasks/test_tcp.yaml
@@ -0,0 +1,5 @@
+---
+- name: tcp_test resolve dns1.example.com
+ shell: kdig +tcp @127.0.0.1 dns1.example.com A
+ register: res
+ failed_when: '"192.0.2.1" not in res.stdout'
diff --git a/distro/tests/ansible-roles/knot_dns/tasks/test_udp.yaml b/distro/tests/ansible-roles/knot_dns/tasks/test_udp.yaml
new file mode 100644
index 0000000..6ab3245
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/tasks/test_udp.yaml
@@ -0,0 +1,5 @@
+---
+- name: udp_test resolve dns1.example.com
+ shell: kdig @127.0.0.1 dns1.example.com A
+ register: res
+ failed_when: '"192.0.2.1" not in res.stdout'
diff --git a/distro/tests/ansible-roles/knot_dns/vars/CentOS.yaml b/distro/tests/ansible-roles/knot_dns/vars/CentOS.yaml
new file mode 100644
index 0000000..90f7c9e
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/vars/CentOS.yaml
@@ -0,0 +1,5 @@
+---
+show_package_version: rpm -qi knot | grep '^Version'
+packages:
+ - knot
+ - knot-utils
diff --git a/distro/tests/ansible-roles/knot_dns/vars/Debian.yaml b/distro/tests/ansible-roles/knot_dns/vars/Debian.yaml
new file mode 100644
index 0000000..1b744d6
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/vars/Debian.yaml
@@ -0,0 +1,5 @@
+---
+show_package_version: dpkg -s knot | grep '^Version'
+packages:
+ - knot
+ - knot-dnsutils
diff --git a/distro/tests/ansible-roles/knot_dns/vars/Fedora.yaml b/distro/tests/ansible-roles/knot_dns/vars/Fedora.yaml
new file mode 100644
index 0000000..90f7c9e
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/vars/Fedora.yaml
@@ -0,0 +1,5 @@
+---
+show_package_version: rpm -qi knot | grep '^Version'
+packages:
+ - knot
+ - knot-utils
diff --git a/distro/tests/ansible-roles/knot_dns/vars/Ubuntu.yaml b/distro/tests/ansible-roles/knot_dns/vars/Ubuntu.yaml
new file mode 100644
index 0000000..1b744d6
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/vars/Ubuntu.yaml
@@ -0,0 +1,5 @@
+---
+show_package_version: dpkg -s knot | grep '^Version'
+packages:
+ - knot
+ - knot-dnsutils
diff --git a/distro/tests/ansible-roles/knot_dns/vars/openSUSE_Leap.yaml b/distro/tests/ansible-roles/knot_dns/vars/openSUSE_Leap.yaml
new file mode 100644
index 0000000..90f7c9e
--- /dev/null
+++ b/distro/tests/ansible-roles/knot_dns/vars/openSUSE_Leap.yaml
@@ -0,0 +1,5 @@
+---
+show_package_version: rpm -qi knot | grep '^Version'
+packages:
+ - knot
+ - knot-utils
diff --git a/distro/tests/ansible-roles/obs_repos/defaults/main.yaml b/distro/tests/ansible-roles/obs_repos/defaults/main.yaml
new file mode 100644
index 0000000..96c6b17
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/defaults/main.yaml
@@ -0,0 +1,3 @@
+---
+obs_distro: "{{ ansible_distribution | replace(' ', '_') }}"
+obs_repofile_url: "https://download.opensuse.org/repositories/home:CZ-NIC:{{ item }}/{{ obs_repo_version }}/home:CZ-NIC:{{ item }}.repo"
diff --git a/distro/tests/ansible-roles/obs_repos/tasks/CentOS.yaml b/distro/tests/ansible-roles/obs_repos/tasks/CentOS.yaml
new file mode 100644
index 0000000..d777cbf
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/tasks/CentOS.yaml
@@ -0,0 +1,12 @@
+---
+- name: Install EPEL
+ yum:
+ name: epel-release
+ state: present
+
+- name: Download repo file(s)
+ get_url:
+ url: "{{ obs_repofile_url }}"
+ dest: /etc/yum.repos.d/home:CZ-NIC:{{ item }}.repo
+ mode: 0644
+ with_items: "{{ repos }}"
diff --git a/distro/tests/ansible-roles/obs_repos/tasks/Debian.yaml b/distro/tests/ansible-roles/obs_repos/tasks/Debian.yaml
new file mode 100644
index 0000000..9d70fd7
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/tasks/Debian.yaml
@@ -0,0 +1,14 @@
+---
+- name: Add upstream package signing key
+ get_url:
+ url: https://gitlab.nic.cz/knot/knot-resolver-release/raw/master/cznic-obs.gpg.asc
+ dest: /etc/apt/trusted.gpg.d/cznic-obs.gpg.asc
+ mode: 0644
+
+- name: Add OBS repo(s)
+ apt_repository:
+ repo: >
+ deb http://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/{{ obs_repo_version }}/ /
+ state: present
+ update_cache: true
+ with_items: "{{ repos }}"
diff --git a/distro/tests/ansible-roles/obs_repos/tasks/Fedora.yaml b/distro/tests/ansible-roles/obs_repos/tasks/Fedora.yaml
new file mode 100644
index 0000000..8e1bbba
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/tasks/Fedora.yaml
@@ -0,0 +1,7 @@
+---
+- name: Download repo file(s)
+ get_url:
+ url: "{{ obs_repofile_url }}"
+ dest: "/etc/yum.repos.d/home:CZ-NIC:{{ item }}.repo"
+ mode: 0644
+ with_items: "{{ repos }}"
diff --git a/distro/tests/ansible-roles/obs_repos/tasks/Ubuntu.yaml b/distro/tests/ansible-roles/obs_repos/tasks/Ubuntu.yaml
new file mode 100644
index 0000000..6b778ac
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/tasks/Ubuntu.yaml
@@ -0,0 +1,13 @@
+---
+- name: Add upstream package signing key
+ apt_key:
+ url: https://gitlab.nic.cz/knot/knot-resolver-release/raw/master/cznic-obs.gpg.asc
+ state: present
+
+- name: Add OBS repo(s)
+ apt_repository:
+ repo: >
+ deb http://download.opensuse.org/repositories/home:/CZ-NIC:/{{ item }}/{{ obs_repo_version }}/ /
+ state: present
+ update_cache: true
+ with_items: "{{ repos }}"
diff --git a/distro/tests/ansible-roles/obs_repos/tasks/main.yaml b/distro/tests/ansible-roles/obs_repos/tasks/main.yaml
new file mode 100644
index 0000000..4f17e87
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/tasks/main.yaml
@@ -0,0 +1,11 @@
+---
+- name: Include Debian specific vars
+ include_vars: "{{ obs_distro }}_{{ ansible_distribution_major_version }}.yaml"
+ when: obs_distro == "Debian"
+
+- name: Include distribution specific vars
+ include_vars: "{{ obs_distro }}.yaml"
+ when: obs_distro != "Debian"
+
+- name: Configure upstream reporitories
+ include: "{{ obs_distro }}.yaml"
diff --git a/distro/tests/ansible-roles/obs_repos/tasks/openSUSE_Leap.yaml b/distro/tests/ansible-roles/obs_repos/tasks/openSUSE_Leap.yaml
new file mode 100644
index 0000000..907f29d
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/tasks/openSUSE_Leap.yaml
@@ -0,0 +1,17 @@
+---
+- name: Install python-xml dependency for zypper_repository
+ shell: zypper install -y python-xml
+ args:
+ warn: false
+
+- name: Add upstream repo(s)
+ zypper_repository:
+ repo: "{{ obs_repofile_url }}"
+ state: present
+ disable_gpg_check: true # auto_import_keys is broken
+ with_items: "{{ repos }}"
+
+- name: Refresh all repositories
+ zypper_repository:
+ repo: '*'
+ runrefresh: true
diff --git a/distro/tests/ansible-roles/obs_repos/vars/CentOS.yaml b/distro/tests/ansible-roles/obs_repos/vars/CentOS.yaml
new file mode 100644
index 0000000..bc75374
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/vars/CentOS.yaml
@@ -0,0 +1,2 @@
+---
+obs_repo_version: "{{ obs_distro }}_{{ ansible_distribution_major_version }}_EPEL"
diff --git a/distro/tests/ansible-roles/obs_repos/vars/Debian_10.yaml b/distro/tests/ansible-roles/obs_repos/vars/Debian_10.yaml
new file mode 100644
index 0000000..bbe23e4
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/vars/Debian_10.yaml
@@ -0,0 +1,2 @@
+---
+obs_repo_version: "{{ obs_distro }}_{{ ansible_distribution_major_version }}"
diff --git a/distro/tests/ansible-roles/obs_repos/vars/Debian_9.yaml b/distro/tests/ansible-roles/obs_repos/vars/Debian_9.yaml
new file mode 100644
index 0000000..085f126
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/vars/Debian_9.yaml
@@ -0,0 +1,2 @@
+---
+obs_repo_version: "{{ obs_distro }}_{{ ansible_distribution_major_version }}.0"
diff --git a/distro/tests/ansible-roles/obs_repos/vars/Fedora.yaml b/distro/tests/ansible-roles/obs_repos/vars/Fedora.yaml
new file mode 100644
index 0000000..bbe23e4
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/vars/Fedora.yaml
@@ -0,0 +1,2 @@
+---
+obs_repo_version: "{{ obs_distro }}_{{ ansible_distribution_major_version }}"
diff --git a/distro/tests/ansible-roles/obs_repos/vars/Ubuntu.yaml b/distro/tests/ansible-roles/obs_repos/vars/Ubuntu.yaml
new file mode 100644
index 0000000..93e92b0
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/vars/Ubuntu.yaml
@@ -0,0 +1,2 @@
+---
+obs_repo_version: "x{{ obs_distro }}_{{ ansible_distribution_version }}"
diff --git a/distro/tests/ansible-roles/obs_repos/vars/openSUSE_Leap.yaml b/distro/tests/ansible-roles/obs_repos/vars/openSUSE_Leap.yaml
new file mode 100644
index 0000000..fc650cc
--- /dev/null
+++ b/distro/tests/ansible-roles/obs_repos/vars/openSUSE_Leap.yaml
@@ -0,0 +1,2 @@
+---
+obs_repo_version: "{{ obs_distro }}_{{ ansible_distribution_version }}"