blob: 13f3142205d04387fece42cceb7c31c43143a508 (
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
---
- name: ensure sl is uninstalled to begin with
yum:
name: sl
state: absent
- name: disable epel
yum_repository:
name: epel
state: absent
- name: disable epel (Idempotant)
yum_repository:
name: epel
state: absent
register: epel_remove
- name: check return values
assert:
that:
- "epel_remove.repo == 'epel'"
- "epel_remove.state == 'absent'"
- name: check Idempotant
assert:
that: not epel_remove.changed
- name: install sl, which should fail
yum:
name: sl
state: present
ignore_errors: yes
register: sl_result
- debug: var=sl_result
- name: check that install failed
assert:
that:
- sl_result.failed
- "sl_result.msg==\"No package matching 'sl' found available, installed or updated\""
- name: re-add epel
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
register: epel_add
- name: check return values
assert:
that:
- "epel_add.repo == 'epel'"
- "epel_add.state == 'present'"
- name: get repolist
shell: yum repolist
register: repolist
- name: ensure epel was added
assert:
that:
- "'epel' in repolist.stdout"
- epel_add.changed
- name: install sl
yum:
name: sl
state: present
register: sl_result
- name: check that sl was successfully installed
assert:
that:
- sl_result.changed
- name: remove sl
yum:
name: sl
state: absent
- name: change configuration of epel repo
yum_repository:
name: epel
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
description: New description
async: no
enablegroups: no
file: epel2
ip_resolve: 4
keepalive: no
register: epel_add
- set_fact:
repofile: "{{ lookup('file', '/etc/yum.repos.d/epel2.repo') }}"
- debug: var=repofile
- name: check that options are correctly getting written to the repo file
assert:
that:
- "'async = 0' in repofile"
- "'name = New description' in repofile"
- "'enablegroups = 0' in repofile"
- "'ip_resolve = 4' in repofile"
- "'keepalive = 0' in repofile"
- name: check new config doesn't change (Idempotant)
yum_repository:
name: epel
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
description: New description
async: no
enablegroups: no
file: epel2
ip_resolve: 4
keepalive: no
register: epel_add
- name: check Idempotant
assert:
that: not epel_add.changed
- name: re-enable the epel repo
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
- name: re-enable the epel repo (Idempotant)
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
register: epel_add
- name: check Idempotant
assert:
that: not epel_add.changed
- name: Test list options
yum_repository:
name: listtest
description: Testing list feature
baseurl:
- https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
- https://download2.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
gpgkey:
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG2-KEY-EPEL-{{ ansible_distribution_major_version }}
exclude:
- aaa
- bbb
includepkgs:
- ccc
- ddd
- set_fact:
repofile: "{{ lookup('file', '/etc/yum.repos.d/listtest.repo') }}"
- name: Assert that lists were properly inserted
assert:
that:
- "'download.fedoraproject.org' in repofile"
- "'download2.fedoraproject.org' in repofile"
- "'RPM-GPG-KEY-EPEL' in repofile"
- "'RPM-GPG2-KEY-EPEL' in repofile"
- "'aaa bbb' in repofile"
- "'ccc ddd' in repofile"
- name: Cleanup list test repo
yum_repository:
name: listtest
state: absent
- name: disable epel (clean up)
yum_repository:
name: epel
state: absent
- name: add epel
yum_repository:
name: epel
description: EPEL yum repo
baseurl: https://download.fedoraproject.org/pub/epel/{{ ansible_distribution_major_version }}/{{ ansible_architecture }}/
state: present
gpgcheck: no
- set_fact:
repofile: "{{ lookup('file', '/etc/yum.repos.d/epel.repo') }}"
- name: check for gpgcheck=0
assert:
that:
- "'gpgcheck = 0' in repofile"
|