ansible/test/integration/targets/ansible-galaxy-role/tasks/main.yml
Alexander Sowitzki 1c83672532
Allow $ & ~ inside paths in galaxy roles (#72966)
ansible-galaxy currently behaves bad then a role to be installed
contains ~ or $ at any place in the path of a file in that role.
It extracts the parent directory of the offending path level as an
empty file. This explodes if that directory contains anything else.

Change this behaviour. `~` is now allowed allowed when it is
not a full level (Yes: `some~thing/`, no: `~/`). The code should
get refactoring in an other PR.
2021-02-02 18:10:05 +01:00

58 lines
1.5 KiB
YAML

- name: Archive directories
file:
state: directory
path: "{{ remote_tmp_dir }}/role.d/{{item}}"
loop:
- meta
- tasks
- name: Metadata file
copy:
content: "'galaxy_info': {}"
dest: "{{ remote_tmp_dir }}/role.d/meta/main.yml"
- name: Valid files
copy:
content: ""
dest: "{{ remote_tmp_dir }}/role.d/tasks/{{item}}"
loop:
- "main.yml"
- "valid~file.yml"
- name: Valid role archive
command: "tar cf {{ remote_tmp_dir }}/valid-role.tar {{ remote_tmp_dir }}/role.d"
- name: Invalid file
copy:
content: ""
dest: "{{ remote_tmp_dir }}/role.d/tasks/~invalid.yml"
- name: Valid requirements file
copy:
dest: valid-requirements.yml
content: "[{'src': '{{ remote_tmp_dir }}/valid-role.tar', 'name': 'valid-testrole'}]"
- name: Invalid role archive
command: "tar cf {{ remote_tmp_dir }}/invalid-role.tar {{ remote_tmp_dir }}/role.d"
- name: Invalid requirements file
copy:
dest: invalid-requirements.yml
content: "[{'src': '{{ remote_tmp_dir }}/invalid-role.tar', 'name': 'invalid-testrole'}]"
- name: Install valid role
command: ansible-galaxy install -r valid-requirements.yml
- name: Uninstall valid role
command: ansible-galaxy role remove valid-testrole
- name: Install invalid role
command: ansible-galaxy install -r invalid-requirements.yml
ignore_errors: yes
register: invalid
- assert:
that: "invalid.rc != 0"
- name: Uninstall invalid role
command: ansible-galaxy role remove invalid-testrole