Debian Codegraph @

ansible_collections/community/hashi_vault/tests/integration/targets/connection_options/tasks/controller.yml

raw
1 ---
2 - name: Connection Tests
3 module_defaults:
4 assert:
5 quiet: true
6 vars:
7 # we don't set kwargs: {} here because of https://github.com/ansible/ansible/issues/75286
8 test_cmd: &test
9 set_fact:
10 result: "{{ lookup('vault_test_connection', '', **kwargs) }}"
11 assert_cmd: &assert
12 assert:
13 that: result.status.initialized
14 block:
15 - name: HTTP connection
16 vars:
17 kwargs: {}
18 block:
19 - name: Set the HTTP connection address
20 set_fact:
21 ansible_hashi_vault_url: '{{ vault_test_server_http }}'
22
23 - name: test HTTP
24 <<: *test
25
26 - <<: *assert
27
28 - name: test HTTP with proxy
29 <<: *test
30 vars:
31 kwargs:
32 url: '{{ vault_proxy_alt_vault_http | default(vault_test_server_http) }}'
33 proxies: '{{ vault_proxy_server }}'
34
35 - <<: *assert
36
37 - name: test HTTP with wrong proxy
38 <<: *test
39 vars:
40 vault_test_connection_want_exception: true
41 ansible_hashi_vault_proxies: http://127.0.0.1:4567
42 ansible_hashi_vault_retries: 2
43
44 - assert:
45 that:
46 - result is failed
47 - result.msg is search('(?:Cannot|Unable to) connect to proxy')
48 - result.retries == 2
49
50 - name: HTTPS connection
51 when: vault_run_https_tests | bool
52 vars:
53 kwargs: &kwargs
54 ca_cert: '{{ vault_cert_file }}'
55 block:
56 - name: Set the HTTPS connection address
57 set_fact:
58 ansible_hashi_vault_addr: '{{ vault_test_server_https }}'
59
60 - name: test HTTPS with no cert validation
61 <<: *test
62 vars:
63 ansible_hashi_vault_validate_certs: false
64
65 - <<: *assert
66
67 - name: test HTTPS with no cert validation and retries
68 <<: *test
69 vars:
70 ansible_hashi_vault_validate_certs: false
71 ansible_hashi_vault_retries: 2
72
73 - <<: *assert
74
75 - name: test HTTPS with cert validation
76 <<: *test
77 vars:
78 vault_test_connection_want_args: true
79 vault_test_connection_want_exception: true
80
81 - <<: *assert
82
83 - name: test HTTPS with cert validation and retries
84 <<: *test
85 vars:
86 vault_test_connection_want_args: true
87 vault_test_connection_want_exception: true
88 ansible_hashi_vault_retries: 2
89
90 - <<: *assert
91
92 - name: test HTTPS with proxy & cert validation
93 <<: *test
94 vars:
95 kwargs:
96 <<: *kwargs
97 url: '{{ vault_proxy_alt_vault_https | default(vault_test_server_http) }}'
98 proxies: '{{ vault_proxy_server }}'
99
100 - <<: *assert
101
102 - name: test HTTPS with wrong proxy & cert validation
103 <<: *test
104 vars:
105 vault_test_connection_want_exception: true
106 ansible_hashi_vault_validate_certs: true
107 ansible_hashi_vault_proxies: http://127.0.0.1:4567
108 ansible_hashi_vault_retries: 2
109
110 - assert:
111 that:
112 - result is failed
113 - result.msg is search('(?:Cannot|Unable to) connect to proxy')
114 - result.retries == 2