blob: 828f71e24b95776e40156204059f1385ea357d1e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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
|