2018-10-11 17:51:40 +00:00
|
|
|
- name: test yum proxy settings
|
|
|
|
block:
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: install tinyproxy
|
|
|
|
yum:
|
2018-10-11 17:51:40 +00:00
|
|
|
name: 'https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/yum/tinyproxy-1.10.0-3.el7.x86_64.rpm'
|
|
|
|
state: installed
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
# 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: install ninvaders with unauthenticated proxy
|
|
|
|
yum:
|
|
|
|
name: 'https://s3.amazonaws.com/ansible-ci-files/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: 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:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/tinyproxy/tinyproxy.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "BasicAuth 1testuser 1testpassword"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: present
|
|
|
|
|
|
|
|
# systemd doesn't play nice with this in a container for some reason
|
2019-02-09 06:17:22 +00:00
|
|
|
- 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}')
|
2018-10-11 17:51:40 +00:00
|
|
|
changed_when: false
|
2019-02-09 06:17:22 +00:00
|
|
|
args:
|
|
|
|
executable: /usr/bin/bash
|
2018-10-11 17:51:40 +00:00
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: set authenticated proxy config in yum.conf
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: present
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: install ninvaders with authenticated proxy
|
|
|
|
yum:
|
2018-10-11 17:51:40 +00:00
|
|
|
name: 'https://s3.amazonaws.com/ansible-ci-files/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"
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: uninstall ninvaders with authenticated proxy
|
|
|
|
yum:
|
2018-10-11 17:51:40 +00:00
|
|
|
name: ninvaders
|
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: unset authenticated proxy config in yum.conf
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: set proxy config in yum.conf
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
|
|
|
line: "proxy=http://127.0.0.1:8888"
|
|
|
|
state: present
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: set proxy_username config in yum.conf
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy_username=1testuser"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: present
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: set proxy_password config in yum.conf
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy_password=1testpassword"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: present
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: install ninvaders with proxy, proxy_username, and proxy_password config in yum.conf
|
|
|
|
yum:
|
2018-10-11 17:51:40 +00:00
|
|
|
name: 'https://s3.amazonaws.com/ansible-ci-files/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"
|
|
|
|
|
|
|
|
always:
|
2019-02-09 06:17:22 +00:00
|
|
|
#cleanup
|
|
|
|
- name: uninstall tinyproxy
|
|
|
|
yum:
|
2018-10-11 17:51:40 +00:00
|
|
|
name: tinyproxy
|
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: uninstall ninvaders
|
|
|
|
yum:
|
2018-10-11 17:51:40 +00:00
|
|
|
name: ninvaders
|
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: ensure unset authenticated proxy
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: ensure unset proxy
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
|
|
|
line: "proxy=http://127.0.0.1:8888"
|
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: ensure unset proxy_username
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy_username=1testuser"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: absent
|
|
|
|
|
2019-02-09 06:17:22 +00:00
|
|
|
- name: ensure unset proxy_password
|
|
|
|
lineinfile:
|
2018-10-11 17:51:40 +00:00
|
|
|
path: /etc/yum.conf
|
2018-10-30 15:35:37 +00:00
|
|
|
line: "proxy_password=1testpassword"
|
2018-10-11 17:51:40 +00:00
|
|
|
state: absent
|
|
|
|
when:
|
|
|
|
- (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7)
|