summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorAlexander Sowitzki <asowitzk@redhat.com>2021-02-02 18:10:05 +0100
committerGitHub <noreply@github.com>2021-02-02 18:10:05 +0100
commit1c83672532330d0d26b63f8a97ee703e7fc697df (patch)
tree490ec961a72ab3f4bcaa2cdda7a9cc55903e245d /test/integration
parentOverhaul ansible-test SSH key management. (#73451) (diff)
downloadansible-1c83672532330d0d26b63f8a97ee703e7fc697df.tar.xz
ansible-1c83672532330d0d26b63f8a97ee703e7fc697df.zip
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.
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/targets/ansible-galaxy-role/aliases2
-rw-r--r--test/integration/targets/ansible-galaxy-role/meta/main.yml1
-rw-r--r--test/integration/targets/ansible-galaxy-role/tasks/main.yml58
3 files changed, 61 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-galaxy-role/aliases b/test/integration/targets/ansible-galaxy-role/aliases
new file mode 100644
index 0000000000..62548acd35
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+skip/python2.6 # build uses tarfile with features not available until 2.7
diff --git a/test/integration/targets/ansible-galaxy-role/meta/main.yml b/test/integration/targets/ansible-galaxy-role/meta/main.yml
new file mode 100644
index 0000000000..e6bc9ccb62
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/meta/main.yml
@@ -0,0 +1 @@
+dependencies: [setup_remote_tmp_dir]
diff --git a/test/integration/targets/ansible-galaxy-role/tasks/main.yml b/test/integration/targets/ansible-galaxy-role/tasks/main.yml
new file mode 100644
index 0000000000..e49e4e2958
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/tasks/main.yml
@@ -0,0 +1,58 @@
+- 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