| 1 |
--- |
| 2 |
# Copyright (c) Ansible Project |
| 3 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
################################################### |
| 7 |
- name: Make directory install_c |
| 8 |
ansible.builtin.file: |
| 9 |
path: "{{ remote_tmp_dir }}/install_c" |
| 10 |
state: directory |
| 11 |
|
| 12 |
- name: Install collection netbox.netbox |
| 13 |
community.general.ansible_galaxy_install: |
| 14 |
type: collection |
| 15 |
name: netbox.netbox |
| 16 |
dest: "{{ remote_tmp_dir }}/install_c" |
| 17 |
register: install_c0 |
| 18 |
|
| 19 |
- name: Assert collection netbox.netbox was installed |
| 20 |
assert: |
| 21 |
that: |
| 22 |
- install_c0 is changed |
| 23 |
- '"netbox.netbox" in install_c0.new_collections' |
| 24 |
|
| 25 |
- name: Install collection netbox.netbox (again) |
| 26 |
community.general.ansible_galaxy_install: |
| 27 |
type: collection |
| 28 |
name: netbox.netbox |
| 29 |
dest: "{{ remote_tmp_dir }}/install_c" |
| 30 |
register: install_c1 |
| 31 |
|
| 32 |
- name: Assert collection was not installed |
| 33 |
assert: |
| 34 |
that: |
| 35 |
- install_c1 is not changed |
| 36 |
|
| 37 |
################################################### |
| 38 |
- name: Make directory install_r |
| 39 |
ansible.builtin.file: |
| 40 |
path: "{{ remote_tmp_dir }}/install_r" |
| 41 |
state: directory |
| 42 |
|
| 43 |
- name: Install role ansistrano.deploy |
| 44 |
community.general.ansible_galaxy_install: |
| 45 |
type: role |
| 46 |
name: ansistrano.deploy |
| 47 |
dest: "{{ remote_tmp_dir }}/install_r" |
| 48 |
register: install_r0 |
| 49 |
|
| 50 |
- name: Assert collection ansistrano.deploy was installed |
| 51 |
assert: |
| 52 |
that: |
| 53 |
- install_r0 is changed |
| 54 |
- '"ansistrano.deploy" in install_r0.new_roles' |
| 55 |
|
| 56 |
- name: Install role ansistrano.deploy (again) |
| 57 |
community.general.ansible_galaxy_install: |
| 58 |
type: role |
| 59 |
name: ansistrano.deploy |
| 60 |
dest: "{{ remote_tmp_dir }}/install_r" |
| 61 |
register: install_r1 |
| 62 |
|
| 63 |
- name: Assert role was not installed |
| 64 |
assert: |
| 65 |
that: |
| 66 |
- install_r1 is not changed |
| 67 |
|
| 68 |
################################################### |
| 69 |
- name: Set requirements file path |
| 70 |
set_fact: |
| 71 |
reqs_file: '{{ remote_tmp_dir }}/reqs.yaml' |
| 72 |
|
| 73 |
- name: Copy requirements file |
| 74 |
copy: |
| 75 |
src: 'files/test.yml' |
| 76 |
dest: '{{ reqs_file }}' |
| 77 |
|
| 78 |
- name: Install from requirements file |
| 79 |
community.general.ansible_galaxy_install: |
| 80 |
type: both |
| 81 |
requirements_file: "{{ reqs_file }}" |
| 82 |
register: install_rq0 |
| 83 |
ignore_errors: true |
| 84 |
|
| 85 |
- name: Assert requirements file was installed |
| 86 |
assert: |
| 87 |
that: |
| 88 |
- install_rq0 is changed |
| 89 |
- '"geerlingguy.java" in install_rq0.new_roles' |
| 90 |
- '"geerlingguy.php_roles" in install_rq0.new_collections' |
| 91 |
|
| 92 |
- name: Install from requirements file (again) |
| 93 |
community.general.ansible_galaxy_install: |
| 94 |
type: both |
| 95 |
requirements_file: "{{ reqs_file }}" |
| 96 |
register: install_rq1 |
| 97 |
ignore_errors: true |
| 98 |
|
| 99 |
- name: Assert requirements file was not installed |
| 100 |
assert: |
| 101 |
that: |
| 102 |
- install_rq1 is not changed |
| 103 |
|
| 104 |
################################################### |
| 105 |
- name: Make directory upgrade_c |
| 106 |
ansible.builtin.file: |
| 107 |
path: "{{ remote_tmp_dir }}/upgrade_c" |
| 108 |
state: directory |
| 109 |
|
| 110 |
- name: Install collection netbox.netbox 3.17.0 |
| 111 |
community.general.ansible_galaxy_install: |
| 112 |
type: collection |
| 113 |
name: netbox.netbox:3.17.0 |
| 114 |
dest: "{{ remote_tmp_dir }}/upgrade_c" |
| 115 |
register: upgrade_c0 |
| 116 |
|
| 117 |
- name: Assert collection netbox.netbox was installed |
| 118 |
assert: |
| 119 |
that: |
| 120 |
- upgrade_c0 is changed |
| 121 |
- '"netbox.netbox" in upgrade_c0.new_collections' |
| 122 |
|
| 123 |
- name: Upgrade collection netbox.netbox |
| 124 |
community.general.ansible_galaxy_install: |
| 125 |
state: latest |
| 126 |
type: collection |
| 127 |
name: netbox.netbox |
| 128 |
dest: "{{ remote_tmp_dir }}/upgrade_c" |
| 129 |
register: upgrade_c1 |
| 130 |
|
| 131 |
- name: Upgrade collection netbox.netbox (again) |
| 132 |
community.general.ansible_galaxy_install: |
| 133 |
state: latest |
| 134 |
type: collection |
| 135 |
name: netbox.netbox |
| 136 |
dest: "{{ remote_tmp_dir }}/upgrade_c" |
| 137 |
register: upgrade_c2 |
| 138 |
|
| 139 |
- name: Assert collection was not installed |
| 140 |
assert: |
| 141 |
that: |
| 142 |
- upgrade_c1 is changed |
| 143 |
- upgrade_c2 is not changed |
| 144 |
|
| 145 |
################################################### |
| 146 |
- name: Find ansible-galaxy executable path |
| 147 |
ansible.builtin.command: which ansible-galaxy |
| 148 |
register: galaxy_which |
| 149 |
changed_when: false |
| 150 |
|
| 151 |
- name: Make directory exec_c |
| 152 |
ansible.builtin.file: |
| 153 |
path: "{{ remote_tmp_dir }}/exec_c" |
| 154 |
state: directory |
| 155 |
|
| 156 |
- name: Install collection using explicit executable path |
| 157 |
community.general.ansible_galaxy_install: |
| 158 |
type: collection |
| 159 |
name: netbox.netbox |
| 160 |
dest: "{{ remote_tmp_dir }}/exec_c" |
| 161 |
executable: "{{ galaxy_which.stdout }}" |
| 162 |
register: exec_c0 |
| 163 |
|
| 164 |
- name: Assert collection was installed using explicit executable |
| 165 |
assert: |
| 166 |
that: |
| 167 |
- exec_c0 is changed |
| 168 |
- '"netbox.netbox" in exec_c0.new_collections' |
| 169 |
- exec_c0.executable == galaxy_which.stdout |
| 170 |
|
| 171 |
- name: Fail to install collection using bad executable path |
| 172 |
community.general.ansible_galaxy_install: |
| 173 |
type: collection |
| 174 |
name: netbox.netbox |
| 175 |
dest: "{{ remote_tmp_dir }}/exec_c" |
| 176 |
executable: /nonexistent/ansible-galaxy |
| 177 |
register: exec_c_fail |
| 178 |
ignore_errors: true |
| 179 |
|
| 180 |
- name: Assert bad executable caused failure |
| 181 |
assert: |
| 182 |
that: |
| 183 |
- exec_c_fail is failed |