2016-05-11 05:43:07 +02:00
|
|
|
# The docker --link functionality gives us an ENV var we can key off of to see if we have access to
|
|
|
|
# the httptester container
|
|
|
|
- set_fact:
|
2016-05-31 23:47:36 +02:00
|
|
|
has_httptester: "{{ lookup('env', 'HTTPTESTER') != '' }}"
|
2016-05-11 05:43:07 +02:00
|
|
|
|
2018-10-13 00:20:00 +02:00
|
|
|
- name: make sure we have the ansible_os_family and ansible_distribution_version facts
|
|
|
|
setup:
|
|
|
|
gather_subset: distribution
|
|
|
|
when: ansible_facts == {}
|
|
|
|
|
2016-05-11 05:43:07 +02:00
|
|
|
# If we are running with access to a httptester container, grab it's cacert and install it
|
|
|
|
- block:
|
|
|
|
# Override hostname defaults with httptester linked names
|
|
|
|
- include_vars: httptester.yml
|
|
|
|
|
2018-10-19 05:43:54 +02:00
|
|
|
# Server 2008 R2 uses a 3rd party program to foward the ports and it may
|
|
|
|
# not be ready straight away, we give it at least 5 minutes before
|
|
|
|
# conceding defeat
|
|
|
|
- name: make sure the port forwarder is active - Windows
|
|
|
|
win_wait_for:
|
|
|
|
host: ansible.http.tests
|
|
|
|
port: 80
|
|
|
|
state: started
|
|
|
|
timeout: 300
|
|
|
|
when: ansible_os_family == 'Windows'
|
|
|
|
|
2016-05-11 05:43:07 +02:00
|
|
|
- name: RedHat - Enable the dynamic CA configuration feature
|
|
|
|
command: update-ca-trust force-enable
|
|
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
|
|
|
|
- name: RedHat - Retrieve test cacert
|
|
|
|
get_url:
|
|
|
|
url: "http://ansible.http.tests/cacert.pem"
|
|
|
|
dest: "/etc/pki/ca-trust/source/anchors/ansible.pem"
|
|
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
|
2017-04-07 18:54:37 +02:00
|
|
|
- name: Get client cert/key
|
|
|
|
get_url:
|
|
|
|
url: "http://ansible.http.tests/{{ item }}"
|
2019-01-25 04:25:06 +01:00
|
|
|
dest: "{{ remote_tmp_dir }}/{{ item }}"
|
2018-10-13 00:20:00 +02:00
|
|
|
when: ansible_os_family != 'Windows'
|
|
|
|
with_items:
|
|
|
|
- client.pem
|
|
|
|
- client.key
|
|
|
|
|
|
|
|
- name: Windows - Get client cert/key
|
|
|
|
win_get_url:
|
|
|
|
url: http://ansible.http.tests/{{ item }}
|
2019-03-04 04:18:45 +01:00
|
|
|
dest: '{{ remote_tmp_dir }}\{{ item }}'
|
2018-10-19 07:15:03 +02:00
|
|
|
register: win_download
|
|
|
|
# Server 2008 R2 is slightly slower, we attempt 5 retries
|
|
|
|
retries: 5
|
|
|
|
until: win_download is successful
|
2018-10-13 00:20:00 +02:00
|
|
|
when: ansible_os_family == 'Windows'
|
2017-04-07 18:54:37 +02:00
|
|
|
with_items:
|
|
|
|
- client.pem
|
|
|
|
- client.key
|
|
|
|
|
2016-05-31 23:47:36 +02:00
|
|
|
- name: Suse - Retrieve test cacert
|
|
|
|
get_url:
|
|
|
|
url: "http://ansible.http.tests/cacert.pem"
|
|
|
|
dest: "/etc/pki/trust/anchors/ansible.pem"
|
|
|
|
when: ansible_os_family == 'Suse'
|
|
|
|
|
2016-05-11 05:43:07 +02:00
|
|
|
- name: Debian - Retrieve test cacert
|
|
|
|
get_url:
|
|
|
|
url: "http://ansible.http.tests/cacert.pem"
|
|
|
|
dest: "/usr/local/share/ca-certificates/ansible.crt"
|
|
|
|
when: ansible_os_family == 'Debian'
|
|
|
|
|
2018-10-13 00:20:00 +02:00
|
|
|
- name: Windows - Retrieve test cacert
|
|
|
|
win_get_url:
|
|
|
|
url: http://ansible.http.tests/cacert.pem
|
2019-03-04 04:18:45 +01:00
|
|
|
dest: '{{ remote_tmp_dir }}\cacert.pem'
|
2018-10-13 00:20:00 +02:00
|
|
|
when: ansible_os_family == 'Windows'
|
|
|
|
|
2016-05-11 05:43:07 +02:00
|
|
|
- name: Redhat - Update ca trust
|
|
|
|
command: update-ca-trust extract
|
|
|
|
when: ansible_os_family == 'RedHat'
|
|
|
|
|
2016-05-31 23:47:36 +02:00
|
|
|
- name: Debian/Suse - Update ca certificates
|
2016-05-11 05:43:07 +02:00
|
|
|
command: update-ca-certificates
|
2016-05-31 23:47:36 +02:00
|
|
|
when: ansible_os_family == 'Debian' or ansible_os_family == 'Suse'
|
2016-05-11 05:43:07 +02:00
|
|
|
|
2018-10-13 00:20:00 +02:00
|
|
|
- name: Windows - Update ca trust
|
|
|
|
win_certificate_store:
|
2019-03-04 04:18:45 +01:00
|
|
|
path: '{{ remote_tmp_dir }}\cacert.pem'
|
2018-10-13 00:20:00 +02:00
|
|
|
state: present
|
|
|
|
store_location: LocalMachine
|
|
|
|
store_name: Root
|
|
|
|
when: ansible_os_family == 'Windows'
|
|
|
|
|
2018-05-09 18:24:39 +02:00
|
|
|
- name: FreeBSD - Retrieve test cacert
|
|
|
|
get_url:
|
|
|
|
url: "http://ansible.http.tests/cacert.pem"
|
|
|
|
dest: "/tmp/ansible.pem"
|
|
|
|
when: ansible_os_family == 'FreeBSD'
|
|
|
|
|
|
|
|
- name: FreeBSD - Add cacert to root certificate store
|
|
|
|
blockinfile:
|
|
|
|
path: "/etc/ssl/cert.pem"
|
|
|
|
block: "{{ lookup('file', '/tmp/ansible.pem') }}"
|
|
|
|
when: ansible_os_family == 'FreeBSD'
|
|
|
|
|
|
|
|
- name: MacOS - Retrieve test cacert
|
|
|
|
get_url:
|
|
|
|
url: "http://ansible.http.tests/cacert.pem"
|
|
|
|
dest: "/usr/local/etc/openssl/certs/ansible.pem"
|
|
|
|
when: ansible_os_family == 'Darwin'
|
|
|
|
|
|
|
|
- name: MacOS - Update ca certificates
|
|
|
|
command: /usr/local/opt/openssl/bin/c_rehash
|
|
|
|
when: ansible_os_family == 'Darwin'
|
|
|
|
|
2018-10-13 00:20:00 +02:00
|
|
|
when:
|
|
|
|
- has_httptester|bool
|
|
|
|
# skip the setup if running on Windows Server 2008 as httptester is not available
|
|
|
|
- ansible_os_family != 'Windows' or (ansible_os_family == 'Windows' and not ansible_distribution_version.startswith("6.0."))
|