summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-galaxy-collection/tasks/unsupported_resolvelib.yml
blob: a208b2952e36588da06d561f49c5fc089a777b97 (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
- vars:
    venv_cmd: "{{ ansible_python_interpreter ~ ' -m venv' }}"
    venv_dest: "{{ galaxy_dir }}/test_resolvelib_{{ resolvelib_version }}"
  block:
    - name: install another version of resolvelib that is unsupported by ansible-galaxy
      pip:
        name: resolvelib
        version: "{{ resolvelib_version }}"
        state: present
        virtualenv_command: "{{ venv_cmd }}"
        virtualenv: "{{ venv_dest }}"
        virtualenv_site_packages: True

    - name: create test collection install directory - {{ test_name }}
      file:
        path: '{{ galaxy_dir }}/ansible_collections'
        state: directory

    - name: install simple collection from first accessible server (expected failure)
      command: "ansible-galaxy collection install namespace1.name1 {{ galaxy_verbosity }}"
      environment:
        ANSIBLE_COLLECTIONS_PATH: '{{ galaxy_dir }}/ansible_collections'
        PATH: "{{ venv_dest }}/bin:{{ ansible_env.PATH }}"
      register: resolvelib_version_error
      ignore_errors: yes

    - assert:
        that:
          - resolvelib_version_error is failed
          - resolvelib_version_error.stderr | regex_search(error)
      vars:
        error: "({{ import_error }}|{{ compat_error }})"
        import_error: "Failed to import resolvelib"
        compat_error: "ansible-galaxy requires resolvelib<{{major_minor_patch}},>={{major_minor_patch}}"
        major_minor_patch: "[0-9]\\d*\\.[0-9]\\d*\\.[0-9]\\d*"

  always:
    - name: cleanup venv and install directory
      file:
        path: '{{ galaxy_dir }}/ansible_collections'
        state: absent
      loop:
        - '{{ galaxy_dir }}/ansible_collections'
        - '{{ venv_dest }}'