blob: b011d11b31e6eabaea6b32e5c74b1af0ea342686 (
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
|
- name: test yum proxy settings
block:
- name: install tinyproxy
yum:
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/tinyproxy-1.10.0-3.el7.x86_64.rpm'
state: installed
# systemd doesn't play nice with this in a container for some reason
- name: start tinyproxy (systemd with tiny proxy does not work in container)
shell: tinyproxy
changed_when: false
# test proxy without auth
- name: set unauthenticated proxy in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy=http://127.0.0.1:8888"
state: present
- name: clear proxy logs
shell: ': > /var/log/tinyproxy/tinyproxy.log'
changed_when: false
args:
executable: /usr/bin/bash
- name: install ninvaders with unauthenticated proxy
yum:
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
state: installed
register: yum_proxy_result
- assert:
that:
- "yum_proxy_result.changed"
- "'msg' in yum_proxy_result"
- "'rc' in yum_proxy_result"
- name: check that it install via unauthenticated proxy
command: grep -q Request /var/log/tinyproxy/tinyproxy.log
- name: uninstall ninvaders with unauthenticated proxy
yum:
name: ninvaders
state: absent
register: yum_proxy_result
- assert:
that:
- "yum_proxy_result.changed"
- "'msg' in yum_proxy_result"
- "'rc' in yum_proxy_result"
- name: unset unauthenticated proxy in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy=http://127.0.0.1:8888"
state: absent
# test proxy with auth
- name: set authenticated proxy config in tinyproxy.conf
lineinfile:
path: /etc/tinyproxy/tinyproxy.conf
line: "BasicAuth 1testuser 1testpassword"
state: present
# systemd doesn't play nice with this in a container for some reason
- name: SIGHUP tinyproxy to reload config (workaround because of systemd+tinyproxy in container)
shell: kill -HUP $(ps -ef | grep tinyproxy | grep -v grep | awk '{print $2}')
changed_when: false
args:
executable: /usr/bin/bash
- name: set authenticated proxy config in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
state: present
- name: clear proxy logs
shell: ': > /var/log/tinyproxy/tinyproxy.log'
changed_when: false
args:
executable: /usr/bin/bash
- name: install ninvaders with authenticated proxy
yum:
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
state: installed
register: yum_proxy_result
- assert:
that:
- "yum_proxy_result.changed"
- "'msg' in yum_proxy_result"
- "'rc' in yum_proxy_result"
- name: check that it install via authenticated proxy
command: grep -q Request /var/log/tinyproxy/tinyproxy.log
- name: uninstall ninvaders with authenticated proxy
yum:
name: ninvaders
state: absent
- name: unset authenticated proxy config in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
state: absent
- name: set proxy config in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy=http://127.0.0.1:8888"
state: present
- name: set proxy_username config in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy_username=1testuser"
state: present
- name: set proxy_password config in yum.conf
lineinfile:
path: /etc/yum.conf
line: "proxy_password=1testpassword"
state: present
- name: clear proxy logs
shell: ': > /var/log/tinyproxy/tinyproxy.log'
changed_when: false
args:
executable: /usr/bin/bash
- name: install ninvaders with proxy, proxy_username, and proxy_password config in yum.conf
yum:
name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
state: installed
register: yum_proxy_result
- assert:
that:
- "yum_proxy_result.changed"
- "'msg' in yum_proxy_result"
- "'rc' in yum_proxy_result"
- name: check that it install via proxy with proxy_username, proxy_password config in yum.conf
command: grep -q Request /var/log/tinyproxy/tinyproxy.log
always:
#cleanup
- name: uninstall tinyproxy
yum:
name: tinyproxy
state: absent
- name: uninstall ninvaders
yum:
name: ninvaders
state: absent
- name: ensure unset authenticated proxy
lineinfile:
path: /etc/yum.conf
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
state: absent
- name: ensure unset proxy
lineinfile:
path: /etc/yum.conf
line: "proxy=http://127.0.0.1:8888"
state: absent
- name: ensure unset proxy_username
lineinfile:
path: /etc/yum.conf
line: "proxy_username=1testuser"
state: absent
- name: ensure unset proxy_password
lineinfile:
path: /etc/yum.conf
line: "proxy_password=1testpassword"
state: absent
when:
- (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7 and ansible_architecture in ['x86_64'])
|