Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible breaks backwards-compatibility when constructing paths for source files #17877

Closed
cherti opened this issue Oct 3, 2016 · 6 comments
Closed
Assignees
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug.

Comments

@cherti
Copy link

cherti commented Oct 3, 2016

ISSUE TYPE
  • Bug Report, Regression
COMPONENT NAME

tasks-execution, path-creation, to be observed at least in the file- and template-module

ANSIBLE VERSION
ansible 2.2.0
CONFIGURATION

Central ansible-folder changed to ~/.ansible
roles-folder configured to ~/.ansible/roles

OS / ENVIRONMENT

Linux, but most likely unrelated to OS

SUMMARY

template: src=template/{{ item }} dest=/etc/{{ item }} used to work in roles
file: src=template/{{ item }} dest=/etc/{{ item }} used to work as well in roles.

(with_items-section deliberately left out).

With the above mentioned version, this must be changed to
template: src={{ item }} dest=/etc/{{ item }} to work.

STEPS TO REPRODUCE

create a role with files

templates/foobar.txt
tasks/main.yml

in the main.yml, put:

- name: demonstration
  template: src=templates/foobar.txt dest=/etc/foobar.txt

and execute that. With ansible 2.1 this works, with the above noted version, it doesn't.

Error: "Unable to find 'templates/foobar.txt' in expected paths."

Changing to

- name: demonstration
  template: src=foobar.txt dest=/etc/foobar.txt

fixes the issue for the templating module.

@bcoca bcoca added affects_2.2 This issue/PR affects Ansible v2.2 bug_report labels Oct 3, 2016
@bcoca bcoca self-assigned this Oct 3, 2016
@agaffney
Copy link
Contributor

I ran into this in 2.2.0 RC1 using the 'copy' module. The following task:

- name: .vimrc
  copy:
    dest: "{{ homedir }}/.vimrc"
    src: files/vimrc
    owner: "{{ owner }}"
    mode: "{{ default_file_mode }}"

with the source file at roles/<role>/files/vimrc results in:

fatal: [nuc1]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to find 'files/vimrc' in expected paths."}

@agaffney
Copy link
Contributor

Debug output:

  5126 1476327940.53620: search_path:
        /home/agaffney/dev/ansible_stuff/roles/homedir/files/files/vimrc
        /home/agaffney/dev/ansible_stuff/roles/homedir/tasks/files/vimrc
        /home/agaffney/dev/ansible_stuff/roles/homedir/tasks/files/files/vimrc
        /home/agaffney/dev/ansible_stuff/roles/homedir/tasks/tasks/files/vimrc
        /home/agaffney/dev/ansible_stuff/files/files/vimrc
        /home/agaffney/dev/ansible_stuff/files/vimrc

@agaffney
Copy link
Contributor

I created a PR to fix this, but it may not be "correct".

#17995

agaffney added a commit to agaffney/ansible that referenced this issue Oct 15, 2016
bcoca pushed a commit that referenced this issue Oct 17, 2016
(cherry picked from commit 72f0aaf)
(cherry picked from commit ef3fa115d3ba319b7f6a7a86a85655d9cf766120)
@bcoca bcoca closed this as completed in 194c9c4 Oct 17, 2016
@cherti
Copy link
Author

cherti commented Nov 14, 2016

is this fix included 2.2? Because this just hit me with the new ansible 2.2 with the copy-module. As I'm not sure if I should open another issue for this or if it is this code not having landed in 2.2, I thought I might ask here. :)

@agaffney
Copy link
Contributor

Yes, this is fixed as of 2.2.0 RC2. It's likely not the same issue, as I can verify it's still fixed in 2.2.0

@cherti
Copy link
Author

cherti commented Nov 14, 2016

then I'll open another issue for this.

sereinity pushed a commit to sereinity-forks/ansible that referenced this issue Jan 25, 2017
(cherry picked from commit 72f0aaf)
(cherry picked from commit ef3fa115d3ba319b7f6a7a86a85655d9cf766120)
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants