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

Strange things with first_available_file #1391

Closed
tonk opened this issue Oct 20, 2012 · 3 comments
Closed

Strange things with first_available_file #1391

tonk opened this issue Oct 20, 2012 · 3 comments
Milestone

Comments

@tonk
Copy link
Contributor

tonk commented Oct 20, 2012

When I write a playbook like this:

  - name: Deploy process script
    copy: src=process dest=/etc/postfix/process owner=root mode=0750

  - name: Deploy postfix main.cf
    template: src=${item} dest=/etc/postfix/main.cf owner=root mode=0440
    first_available_file:
        - /etc/ansible/play/postfix/main.cf.in=${ansible_hostname}
        - /etc/ansible/play/postfix/main.cf.in
    notify:
        - restart postfix

with the copy I do get a file relative to the playbook YAML file.

The part with the first_available_file requires the full path. When I use a relative path here I get an error.

TASK: [Deploy postfix main.cf] ********************* 
fatal: [master] => {'msg': 'could not find src in first_available_file list', 'failed': True}
fatal: [master] => {'msg': 'could not find src in first_available_file list', 'failed': True}

FATAL: all hosts have already failed -- aborting

Using the absolute path makes things work.
I can't find any documentation on this difference so it feels like a bug.

I propose to make the relative path possible for the first_available_file part as well (if at all possible in the code).

@mpdehaan
Copy link
Contributor

I agree that relative paths should be possible.

Please post the stack trace you are getting.

@tonk
Copy link
Contributor Author

tonk commented Oct 20, 2012

I corrected the above message. It's just the errormessage. The stacktrace had another culprid.

@mpdehaan
Copy link
Contributor

I've fixed the above such that it calls utils.path_dwim around both of these and am going to clarify in the docs that first_available_file is only good for copy and template.

code pushed -- Thanks!

@ansible ansible locked and limited conversation to collaborators Apr 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants