| 1 |
- environment: |
| 2 |
ANSIBLE_NOCOLOR: True |
| 3 |
ANSIBLE_FORCE_COLOR: false |
| 4 |
vars: |
| 5 |
test_base_dir: "{{ [remote_tmp_dir, 'requires_ansible_' ~ subcommand] | path_join }}" |
| 6 |
temp1: "{{ [test_base_dir, 'collections'] | path_join }}" |
| 7 |
temp2: "{{ [test_base_dir, 'other_collections'] | path_join }}" |
| 8 |
install_or_download: "ansible-galaxy collection {{ subcommand }}{{ (subcommand == 'install') | ternary(' --force-with-deps', '')}}" |
| 9 |
failed_error: | |
| 10 |
\[ERROR\]: Failed to resolve the requested dependencies map\. Could not satisfy the following requirements: |
| 11 |
\* ns_requires_ansible\.name_requires_ansible:1\.0\.0 \(direct request\) requires ansible-core <1\.1 |
| 12 |
hint: >- |
| 13 |
Hint: To disregard whether the collection supports the current version |
| 14 |
of ansible-core, configure COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH as "ignore" |
| 15 |
undocumented_warning: >- |
| 16 |
\[WARNING\]: ns_requires_ansible\.name_requires_ansible:.* does not have requires_ansible metadata. |
| 17 |
block: |
| 18 |
- name: "{{ subcommand }} incompatible collection" |
| 19 |
command: "{{ install_or_download }} -p {{ temp1 }} ns_requires_ansible.name_requires_ansible" |
| 20 |
register: expected_fail |
| 21 |
failed_when: expected_fail is success |
| 22 |
|
| 23 |
- assert: |
| 24 |
that: |
| 25 |
- expected_fail.stderr is search(failed_error, multiline=True) |
| 26 |
- expected_fail.stderr is search(hint) |
| 27 |
|
| 28 |
- name: "{{ subcommand }} specific version of incompatible collection" |
| 29 |
command: "{{ install_or_download }} -p {{ temp1 }} 'ns_requires_ansible.name_requires_ansible:1.0.0'" |
| 30 |
register: expected_fail |
| 31 |
failed_when: expected_fail is success |
| 32 |
|
| 33 |
- assert: |
| 34 |
that: |
| 35 |
- expected_fail.stderr is search(failed_error, multiline=True) |
| 36 |
- expected_fail.stderr is search(hint) |
| 37 |
|
| 38 |
- name: Download incompatible tarfile for tarfile tests |
| 39 |
command: ansible-galaxy collection download -p {{ temp1 }} ns_requires_ansible.name_requires_ansible |
| 40 |
environment: |
| 41 |
ANSIBLE_COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH: ignore |
| 42 |
|
| 43 |
- name: "{{ subcommand }} incompatible tarfile" |
| 44 |
command: "{{ install_or_download }} -p {{ temp2 }} {{ temp1 }}/ns_requires_ansible-name_requires_ansible-1.0.0.tar.gz" |
| 45 |
register: expected_fail |
| 46 |
failed_when: expected_fail is success |
| 47 |
|
| 48 |
- assert: |
| 49 |
that: |
| 50 |
- expected_fail.stderr is search(failed_error, multiline=True) |
| 51 |
- expected_fail.stderr is search(hint) |
| 52 |
|
| 53 |
- name: "{{ subcommand }} tarfile and allow mismatched version" |
| 54 |
command: "{{ install_or_download }} -p {{ temp2 }} {{ temp1 }}/ns_requires_ansible-name_requires_ansible-1.0.0.tar.gz" |
| 55 |
environment: |
| 56 |
ANSIBLE_COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH: ignore |
| 57 |
|
| 58 |
- name: setup - {{ subcommand }} build directory |
| 59 |
block: |
| 60 |
- name: setup - init collection build directory |
| 61 |
command: ansible-galaxy collection init ns_requires_ansible.name_requires_ansible --init-path {{ temp2 }}/ansible_collections |
| 62 |
|
| 63 |
- name: setup - add requires_ansible in the runtime file |
| 64 |
shell: >- |
| 65 |
echo 'requires_ansible: "<1.1"' > {{ temp2 }}/ansible_collections/ns_requires_ansible/name_requires_ansible/meta/runtime.yml |
| 66 |
when: subcommand == 'download' |
| 67 |
|
| 68 |
- name: "{{ subcommand }} incompatible directory" |
| 69 |
command: "{{ install_or_download }} -p {{ temp1 }} {{ temp2 }}/ansible_collections/ns_requires_ansible/name_requires_ansible" |
| 70 |
register: expected_fail |
| 71 |
failed_when: expected_fail is success |
| 72 |
|
| 73 |
- assert: |
| 74 |
that: |
| 75 |
- expected_fail.stderr is search(failed_error, multiline=True) |
| 76 |
- expected_fail.stderr is search(hint) |
| 77 |
|
| 78 |
- name: "{{ subcommand }} directory and allow mismatched version" |
| 79 |
command: "{{ install_or_download }} -p {{ temp1 }} {{ temp2 }}/ansible_collections/ns_requires_ansible/name_requires_ansible" |
| 80 |
environment: |
| 81 |
ANSIBLE_COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH: ignore |
| 82 |
|
| 83 |
- name: setup - {{ subcommand }} remove requires_ansible metadata |
| 84 |
file: |
| 85 |
path: "{{ temp2 }}/ansible_collections/ns_requires_ansible/name_requires_ansible/meta/runtime.yml" |
| 86 |
state: absent |
| 87 |
|
| 88 |
- name: "{{ subcommand }} directory with undocumented, optional requires_ansible metadata" |
| 89 |
command: "{{ install_or_download }} -p {{ temp1 }} {{ temp2 }}/ansible_collections/ns_requires_ansible/name_requires_ansible" |
| 90 |
register: expected_success |
| 91 |
|
| 92 |
- assert: |
| 93 |
that: |
| 94 |
- expected_success.stderr is search(undocumented_warning) |
| 95 |
|
| 96 |
- name: "{{ subcommand }} collection with incompatible dependency" |
| 97 |
command: "{{ install_or_download }} -p {{ temp1 }} 'ns_requires_ansible.dependency:2.0.0'" |
| 98 |
register: expected_error |
| 99 |
failed_when: expected_error is not failed |
| 100 |
|
| 101 |
- assert: |
| 102 |
that: |
| 103 |
- expected_error.stderr is search(expected_message, multiline=True) |
| 104 |
vars: |
| 105 |
expected_message: | |
| 106 |
\[ERROR\]: Failed to resolve the requested dependencies map\. Could not satisfy the following requirements: |
| 107 |
\* ns_requires_ansible\.name_requires_ansible:1\.0\.0 \(dependency of ns_requires_ansible\.dependency:2\.0\.0\) requires ansible-core <1\.1 |
| 108 |
|
| 109 |
- name: "{{ subcommand }} collection version without incompatible dependency" |
| 110 |
command: "{{ install_or_download }} -p {{ temp1 }} ns_requires_ansible.dependency" |
| 111 |
register: expected_success |
| 112 |
|
| 113 |
- assert: |
| 114 |
that: |
| 115 |
- expected_success.stdout is search(expected_message) |
| 116 |
vars: |
| 117 |
expected_message: >- |
| 118 |
'?ns_requires_ansible\.dependency:1\.0\.0'? was {{ subcommand }}ed successfully |
| 119 |
|
| 120 |
- name: "{{ subcommand }} collection with unsuccessful backtracking" |
| 121 |
command: "{{ install_or_download }} ns_requires_ansible.backtracking_error" |
| 122 |
register: expected_fail |
| 123 |
failed_when: expected_fail is success |
| 124 |
|
| 125 |
- assert: |
| 126 |
that: |
| 127 |
- expected_fail.stderr is search(expected_message, multiline=True) |
| 128 |
- expected_fail.stderr is search(hint) |
| 129 |
vars: |
| 130 |
expected_message: | |
| 131 |
\[ERROR\]: Failed to resolve the requested dependencies map\. Could not satisfy the following requirements: |
| 132 |
\* ns_requires_ansible\.name_requires_ansible:1\.0\.0 \(dependency of ns_requires_ansible\.dependency_incompat:1\.0\.0\) requires ansible-core <1\.1 |
| 133 |
|
| 134 |
always: |
| 135 |
- name: Clean up test dir |
| 136 |
file: |
| 137 |
path: "{{ test_base_dir }}" |
| 138 |
state: absent |