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

Relative paths don't work correctly when running multiple playbooks from one playbook #12524

Closed
geerlingguy opened this issue Sep 25, 2015 · 6 comments
Assignees
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release
Milestone

Comments

@geerlingguy
Copy link
Contributor

Issue Type:
  • Bug Report
Ansible Version:

ansible 2.0.0 (devel 41756be) last updated 2015/09/25 10:05:38 (GMT -500)

Ansible Configuration:

No changes from defaults.

Environment:

Mac OS X 10.10.4

Summary:

I have a setup where I have one playbook that includes other playbooks.

If I run ansible-playbook with the parent playbook, which includes other playbooks, the relative pathing for tasks inside the other playbooks seems to get stuck or messed up.

If I run ansible-playbook with the child playbooks directly (one-by-one), relative pathing works as expected.

Steps To Reproduce:

This can be reproduced using the example LAMP infrastructure example found here, in the Ansible for DevOps book repository: https://github.com/geerlingguy/ansible-for-devops/tree/master/lamp-infrastructure

I have a directory layout like this:

lamp-infrastructure/
  playbooks/
    memcached/
      main.yml
    varnish/
      templates/
        default.vcl.j2
      main.yml
  configure.yml

Inside configure.yml (a 'master' playbook which simply includes the two children playbooks):

---
- include: playbooks/varnish/main.yml
- include: playbooks/memcached/main.yml

If I run the varnish or memcached main.yml playbooks directly, everything works fine:

ansible-playbook -i inventories/vagrant/inventory playbooks/varnish/main.yml -u vagrant --ask-pass
...
TASK [Copy Varnish default.vcl.] ***********************************************
changed: [192.168.2.2]
...
PLAY RECAP *********************************************************************
192.168.2.2                : ok=18   changed=3    unreachable=0    failed=0 

However, if I run the configure.yml playbook that includes the two main.yml playbooks, it seems Ansible mixes up the paths for tasks like copy.

ansible-playbook -i inventories/vagrant/inventory configure.yml -u vagrant --ask-pass
...
TASK [Copy Varnish default.vcl.] ***********************************************
fatal: [192.168.2.2]: FAILED! => {"changed": false, "failed": true, "msg": "IOError: [Errno 2] No such file or directory: u'/Users/jgeerling/Dropbox/Development/GitHub/ansible-for-devops/lamp-infrastructure/playbooks/memcached/templates/default.vcl.j2'"}
Unexpected Exception: 'unicode' object has no attribute 'name'

Everything works fine in Ansible <= 1.9.3, but fails in Ansible 2.0.0.

Expected Results:

Playbook completes successfully whether run standalone or as part of the master configure.yml playbook.

Actual Results:

Playbook completes successfully when run standalone.

Playbook results in relative pathing error when run as part of the master configure.yml playbook:

TASK [Copy Varnish default.vcl.] ***********************************************
fatal: [192.168.2.2]: FAILED! => {"changed": false, "failed": true, "msg": "IOError: [Errno 2] No such file or directory: u'/Users/jgeerling/Dropbox/Development/GitHub/ansible-for-devops/lamp-infrastructure/playbooks/memcached/templates/default.vcl.j2'"}
Unexpected Exception: 'unicode' object has no attribute 'name'
@jimi-c jimi-c added bug_report P2 Priority 2 - Issue Blocks Release labels Sep 25, 2015
@jimi-c jimi-c added this to the v2 milestone Sep 25, 2015
@jimi-c jimi-c closed this as completed in ffdba96 Sep 29, 2015
@geerlingguy
Copy link
Contributor Author

This seems to have done the trick, thanks!

@goozbach
Copy link
Contributor

I am also having the same issue still

https://github.com/goozbach-ansible/broken-paths for a test case.

running:

$ ansible --version
ansible 2.0.0 (devel 8c29910587) last updated 2015/10/14 13:03:17 (GMT -600)
  lib/ansible/modules/core: (detached HEAD 84b1a1a2b7) last updated 2015/10/14 13:03:21 (GMT-600)
  lib/ansible/modules/extras: (detached HEAD 8ce3104bc5) last updated 2015/10/14 13:03:21 (GMT-600)
  config file = /Users/derekcarter/.ansible.cfg
  configured module search path = None

Platform: OSX

Just did a pull --rebase devel today. So I'm running the latest devel

@jimi-c jimi-c reopened this Oct 16, 2015
@jimi-c
Copy link
Member

jimi-c commented Oct 16, 2015

Reopening to investigate.

@jimi-c jimi-c self-assigned this Oct 16, 2015
@jimi-c jimi-c closed this as completed in a88c59f Oct 17, 2015
@jimi-c
Copy link
Member

jimi-c commented Oct 17, 2015

Closing This Ticket (again)

Hi!

We believe the above commit should resolve this problem for you. This will also be included in the next major release.

If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:

Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved.

Thank you!

@goozbach
Copy link
Contributor

Looks good! THANKS!

@ahill00
Copy link
Contributor

ahill00 commented Nov 6, 2015

Having this issue again.

$ ansible --version
ansible 2.0.0 (devel 59b67a2f68) last updated 2015/11/06 12:46:23 (GMT -400)
  lib/ansible/modules/core: (detached HEAD 22c2789b72) last updated 2015/10/28 23:03:02 (GMT -400)
  lib/ansible/modules/extras: (detached HEAD c685b3d387) last updated 2015/10/28 23:03:10 (GMT -400)
  config file =
  configured module search path = Default w/o overrides

@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
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release
Projects
None yet
Development

No branches or pull requests

5 participants