Debian Codegraph @

test/integration/targets/prepare_http_tests/tasks/kerberos.yml

raw
1 - set_fact:
2 krb5_config: '{{ remote_tmp_dir }}/krb5.conf'
3 krb5_realm: '{{ httpbin_host.split(".")[1:] | join(".") | upper }}'
4 krb5_provider: '{{ (ansible_facts.os_family == "FreeBSD" or ansible_facts.distribution == "MacOSX") | ternary("Heimdal", "MIT") }}'
5 # FreeBSD needs to enable the OpenSSL legacy providers for RC4 support.
6 # While RC4 isn't used Heimdal is currently requiring it as part of a
7 # runtime test, until that is removed we need this hack.
8 # https://github.com/heimdal/heimdal/issues/1224
9 krb5_openssl_conf: >-
10 {{
11 (ansible_facts.os_family == "FreeBSD" and ansible_facts.distribution_major_version in ["14", "15"]) | ternary(
12 remote_tmp_dir ~ "/openssl_legacy.cnf",
13 ""
14 )
15 }}
16
17 - set_fact:
18 krb5_username: admin@{{ krb5_realm }}
19
20 - name: Create krb5.conf file
21 template:
22 src: krb5.conf.j2
23 dest: '{{ krb5_config }}'
24
25 - name: Create openssl.cnf to enable Legacy providers
26 copy:
27 src: openssl_legacy.cnf
28 dest: '{{ krb5_openssl_conf }}'
29 when: krb5_openssl_conf is defined and krb5_openssl_conf is truthy
30
31 - name: Include distribution specific variables
32 include_vars: '{{ lookup("first_found", params) }}'
33 vars:
34 params:
35 files:
36 - '{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml'
37 - '{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml'
38 - '{{ ansible_facts.distribution }}.yml'
39 - '{{ ansible_facts.os_family }}.yml'
40 - default.yml
41 paths:
42 - '{{ role_path }}/vars'
43
44 - name: Install Kerberos system packages
45 package:
46 name: '{{ krb5_packages }}'
47 state: present
48 when: ansible_facts.distribution not in ['Alpine', 'MacOSX']
49
50 # apk isn't available on ansible-core so just call command
51 - name: Alpine - Install Kerberos system packages
52 command: apk add {{ krb5_packages | join(' ') }}
53 when: ansible_facts.distribution == 'Alpine'
54
55 - name: Install python gssapi
56 pip:
57 name: gssapi
58 state: present
59 extra_args: '-c {{ remote_constraints }}'
60 environment:
61 # Put /usr/local/bin for FreeBSD as we need to use the heimdal port over the builtin version
62 # https://github.com/pythongssapi/python-gssapi/issues/228
63 # Need the /usr/lib/mit/bin custom path for OpenSUSE as krb5-config is placed there
64 PATH: '/usr/local/bin:{{ ansible_facts.env.PATH }}:/usr/lib/mit/bin'
65 notify: Remove python gssapi
66
67 - name: test the environment to make sure Kerberos is working properly
68 httptester_kinit:
69 username: '{{ krb5_username }}'
70 password: '{{ krb5_password }}'
71 environment:
72 KRB5_CONFIG: '{{ krb5_config }}'
73 KRB5CCNAME: FILE:{{ remote_tmp_dir }}/krb5.cc
74 OPENSSL_CONF: '{{ krb5_openssl_conf }}'
75
76 - name: remove test credential cache
77 file:
78 path: '{{ remote_tmp_dir }}/krb5.cc'
79 state: absent