ansible / galaxy-issues

This repository exists solely for the tracking of user issues with Ansible Galaxy.
20 stars 3 forks source link

files of the form tasks/<ROLE_NAME>-some-text.yml have their name truncated on install #265

Closed TheWarBadger closed 6 years ago

TheWarBadger commented 7 years ago

Steps to reproduce:

#!/bin/sh -ex
mkdir /tmp/test-galaxy
cd /tmp/test-galaxy
mkdir roles-remote roles
(cd roles-remote && ansible-galaxy init test-role)
cat > roles-remote/test-role/tasks/main.yml <<EOF
---
- include: {{ role_path }}/tasks/test-role-some-tasks.yml
EOF
cat > roles-remote/test-role/tasks/test-role-some-tasks.yml <<EOF
---
- name: print some debug
  debug:
      msg: some debug
EOF
(cd roles-remote/test-role && git init && git add . && git commit -am "initial commit")
ansible-galaxy install git+file:///tmp/test-galaxy/roles-remote/test-role --roles-path=roles
find roles

We expect /tmp/test-galaxy/roles/test-role/tasks/test-role-some-tasks.yml. The file name is truncated to -some-tasks.yml.

Ansible galaxy version 2.3.0.0. Python 2.7.13

chouseknecht commented 6 years ago

@CuriousBadger277

The Galaxy client attempts to reduce the name by removing occurrences of 'ansible' and 'role'. If it's not quite giving you the result you want, I would recommend using a requirements.yml file to perform the install. This would allow you to set the name option, and thereby have explicit control of the installed role name.

See installing multiple roles from a file for assistance.

TheWarBadger commented 6 years ago

Name mangling of the role is sane and well documented. Name mangling the files inside it is unexpected, at least to me.

Naively I would expect the following tasks/main.yml to work:

---
- include: '{{ role_path }}/tasks/test-role-some-tasks.yml"
...

There is an obvious work around to this but as far as I can tell it's just an arbitrary restriction on file names to be used inside a role. I don't remember seeing this in any documentation (please correct me if I'm wrong) and even if it was I can't think of a requirement for it (unless you're worried about file path size limits, at which point a more aggressive breakage would be appreciated).

veryhappythings commented 6 years ago

I've just run up against this today trying to install a collectd role from galaxy. Our requirements file had given it a name of collectd, which results in the etc/collectd/collectd.conf.j2 template being installed as etc/.conf.jw.

The workaround is to add a different name in the requirements file. Just wanted to add my name to the list of people that this has bitten!

chouseknecht commented 6 years ago

@veryhappythings @CuriousBadger277

Looks this was indeed a problem in 2.3.0, and it was resolved. See Ansible issues 22572. According the last comment on that ticket, you will need to upgrade to 2.3.1 to see the change.

Closing, as I believe this to be resolved. Please comment, if otherwise.

Thanks!