summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/prepare_http_tests/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/prepare_http_tests/tasks')
-rw-r--r--test/integration/targets/prepare_http_tests/tasks/default.yml55
-rw-r--r--test/integration/targets/prepare_http_tests/tasks/kerberos.yml65
-rw-r--r--test/integration/targets/prepare_http_tests/tasks/main.yml35
-rw-r--r--test/integration/targets/prepare_http_tests/tasks/windows.yml33
4 files changed, 188 insertions, 0 deletions
diff --git a/test/integration/targets/prepare_http_tests/tasks/default.yml b/test/integration/targets/prepare_http_tests/tasks/default.yml
new file mode 100644
index 0000000..2fb26a1
--- /dev/null
+++ b/test/integration/targets/prepare_http_tests/tasks/default.yml
@@ -0,0 +1,55 @@
+- 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'
+
+- name: Get client cert/key
+ get_url:
+ url: "http://ansible.http.tests/{{ item }}"
+ dest: "{{ remote_tmp_dir }}/{{ item }}"
+ with_items:
+ - client.pem
+ - client.key
+
+- 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'
+
+- name: Debian/Alpine - Retrieve test cacert
+ get_url:
+ url: "http://ansible.http.tests/cacert.pem"
+ dest: "/usr/local/share/ca-certificates/ansible.crt"
+ when: ansible_os_family in ['Debian', 'Alpine']
+
+- name: Redhat - Update ca trust
+ command: update-ca-trust extract
+ when: ansible_os_family == 'RedHat'
+
+- name: Debian/Alpine/Suse - Update ca certificates
+ command: update-ca-certificates
+ when: ansible_os_family in ['Debian', 'Alpine', 'Suse']
+
+- name: Update cacert
+ when: ansible_os_family in ['FreeBSD', 'Darwin']
+ block:
+ - name: Retrieve test cacert
+ uri:
+ url: "http://ansible.http.tests/cacert.pem"
+ return_content: true
+ register: cacert_pem
+
+ - name: Locate cacert
+ command: '{{ ansible_python_interpreter }} -c "import ssl; print(ssl.get_default_verify_paths().cafile)"'
+ register: cafile_path
+
+ - name: Update cacert
+ blockinfile:
+ path: "{{ cafile_path.stdout_lines|first }}"
+ block: "{{ cacert_pem.content }}"
diff --git a/test/integration/targets/prepare_http_tests/tasks/kerberos.yml b/test/integration/targets/prepare_http_tests/tasks/kerberos.yml
new file mode 100644
index 0000000..2678b46
--- /dev/null
+++ b/test/integration/targets/prepare_http_tests/tasks/kerberos.yml
@@ -0,0 +1,65 @@
+- set_fact:
+ krb5_config: '{{ remote_tmp_dir }}/krb5.conf'
+ krb5_realm: '{{ httpbin_host.split(".")[1:] | join(".") | upper }}'
+ krb5_provider: '{{ (ansible_facts.os_family == "FreeBSD" or ansible_facts.distribution == "MacOSX") | ternary("Heimdal", "MIT") }}'
+
+- set_fact:
+ krb5_username: admin@{{ krb5_realm }}
+
+- name: Create krb5.conf file
+ template:
+ src: krb5.conf.j2
+ dest: '{{ krb5_config }}'
+
+- name: Include distribution specific variables
+ include_vars: '{{ lookup("first_found", params) }}'
+ vars:
+ params:
+ files:
+ - '{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml'
+ - '{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml'
+ - '{{ ansible_facts.distribution }}.yml'
+ - '{{ ansible_facts.os_family }}.yml'
+ - default.yml
+ paths:
+ - '{{ role_path }}/vars'
+
+- name: Install Kerberos sytem packages
+ package:
+ name: '{{ krb5_packages }}'
+ state: present
+ when: ansible_facts.distribution not in ['Alpine', 'MacOSX']
+
+# apk isn't available on ansible-core so just call command
+- name: Alpine - Install Kerberos system packages
+ command: apk add {{ krb5_packages | join(' ') }}
+ when: ansible_facts.distribution == 'Alpine'
+
+- name: Install python gssapi
+ pip:
+ name:
+ - decorator < 5.0.0 ; python_version < '3.5' # decorator 5.0.5 and later require python 3.5 or later
+ - gssapi < 1.6.0 ; python_version <= '2.7' # gssapi 1.6.0 and later require python 3 or later
+ - gssapi ; python_version > '2.7'
+ - importlib ; python_version < '2.7'
+ state: present
+ extra_args: '-c {{ remote_constraints }}'
+ environment:
+ # Put /usr/local/bin for FreeBSD as we need to use the heimdal port over the builtin version
+ # https://github.com/pythongssapi/python-gssapi/issues/228
+ # Need the /usr/lib/mit/bin custom path for OpenSUSE as krb5-config is placed there
+ PATH: '/usr/local/bin:{{ ansible_facts.env.PATH }}:/usr/lib/mit/bin'
+ notify: Remove python gssapi
+
+- name: test the environment to make sure Kerberos is working properly
+ httptester_kinit:
+ username: '{{ krb5_username }}'
+ password: '{{ krb5_password }}'
+ environment:
+ KRB5_CONFIG: '{{ krb5_config }}'
+ KRB5CCNAME: FILE:{{ remote_tmp_dir }}/krb5.cc
+
+- name: remove test credential cache
+ file:
+ path: '{{ remote_tmp_dir }}/krb5.cc'
+ state: absent
diff --git a/test/integration/targets/prepare_http_tests/tasks/main.yml b/test/integration/targets/prepare_http_tests/tasks/main.yml
new file mode 100644
index 0000000..8d34a3c
--- /dev/null
+++ b/test/integration/targets/prepare_http_tests/tasks/main.yml
@@ -0,0 +1,35 @@
+# 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:
+ has_httptester: "{{ lookup('env', 'HTTPTESTER') != '' }}"
+
+- name: make sure we have the ansible_os_family and ansible_distribution_version facts
+ setup:
+ gather_subset: distribution
+ when: ansible_facts == {}
+
+# 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
+
+ - include_tasks: "{{ lookup('first_found', files)}}"
+ vars:
+ files:
+ - "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version }}.yml"
+ - "{{ ansible_os_family | lower }}.yml"
+ - "default.yml"
+ 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."))
+
+- set_fact:
+ krb5_password: "{{ lookup('env', 'KRB5_PASSWORD') }}"
+
+- name: setup Kerberos client
+ include_tasks: kerberos.yml
+ when:
+ - has_httptester|bool
+ - ansible_os_family != 'Windows'
+ - krb5_password != ''
diff --git a/test/integration/targets/prepare_http_tests/tasks/windows.yml b/test/integration/targets/prepare_http_tests/tasks/windows.yml
new file mode 100644
index 0000000..da8b0eb
--- /dev/null
+++ b/test/integration/targets/prepare_http_tests/tasks/windows.yml
@@ -0,0 +1,33 @@
+# 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: Windows - make sure the port forwarder is active
+ win_wait_for:
+ host: ansible.http.tests
+ port: 80
+ state: started
+ timeout: 300
+
+- name: Windows - Get client cert/key
+ win_get_url:
+ url: http://ansible.http.tests/{{ item }}
+ dest: '{{ remote_tmp_dir }}\{{ item }}'
+ register: win_download
+ # Server 2008 R2 is slightly slower, we attempt 5 retries
+ retries: 5
+ until: win_download is successful
+ with_items:
+ - client.pem
+ - client.key
+
+- name: Windows - Retrieve test cacert
+ win_get_url:
+ url: http://ansible.http.tests/cacert.pem
+ dest: '{{ remote_tmp_dir }}\cacert.pem'
+
+- name: Windows - Update ca trust
+ win_certificate_store:
+ path: '{{ remote_tmp_dir }}\cacert.pem'
+ state: present
+ store_location: LocalMachine
+ store_name: Root