summaryrefslogtreecommitdiff
path: root/test/integration/targets/tower_organization/tasks/main.yml
blob: 3ddbee993a22b7d8af45be7e38ebd22bf704ee25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
- name: confirm Tower version w/ check mode
  tower_organization:
    name: Default
  check_mode: yes
  register: result

- assert:
    that:
      - "result.tower_version == '{{ tower_version }}'"

- name: Make sure the default Default organization exists
  tower_organization:
    name: Default

- name: Check that SSL is available
  tower_organization:
    name: Default
  register: result

- name: Check we haven't changed anything
  assert:
    that: result is not changed

- name: Check that SSL is available and verify_ssl is enabled (task must fail)
  tower_organization:
    name: Default
  environment:
    TOWER_CERTIFICATE: /dev/null  # force check failure
  ignore_errors: true
  register: check_ssl_is_used

- name: Check that connection failed
  assert:
    that:
      - check_ssl_is_used is failed
      - >
          'Could not establish a secure connection' in (check_ssl_is_used.module_stderr + check_ssl_is_used.module_stdout)
          or 'OpenSSL.SSL.Error' in (check_ssl_is_used.module_stderr + check_ssl_is_used.module_stdout)
        # 'Could not establish a secure connection': when pyOpenSSL isn't available
        # 'OpenSSL.SSL.Error': with pyOpenSSL, see https://github.com/urllib3/urllib3/pull/1517

- name: Disable verify_ssl in ~/.tower_cli.cfg
  copy:
    dest: ~/.tower_cli.cfg
    content: |
      [general]
      verify_ssl = False
    force: false  # ensure remote file doesn't exist

- block:
    - name: Check that verify_ssl is disabled (task must not fail)
      tower_organization:
        name: Default
      environment:
        TOWER_CERTIFICATE: /dev/null  # should not fail because verify_ssl is disabled
  always:
    - name: Delete ~/.tower_cli.cfg
      file:
        path: ~/.tower_cli.cfg
        state: absent