Path to ansible.cfg?

5,031 views
Skip to first unread message

Grzegorz Nosek

unread,
Dec 3, 2013, 1:58:02 PM12/3/13
to ansible...@googlegroups.com
Hi,

The docs at http://www.ansibleworks.com/docs/intro_configuration.html say:

The mechanism for doing this is the “ansible.cfg” file, which is looked
for in the following locations:

* /etc/ansible/ansible.cfg
* ~/.ansible.cfg
* ansible.cfg (in the playbook directory)

However, I noticed that Ansible (v1.4.1) searches for the file in the
_current_ directory (not the playbook directory). Is this a bug in the
docs or am I doing something wrong? I'd like to have a project-wide
ansible.cfg file used with certain playbooks regardless of my current
working directory.

Best regards,
Grzegorz Nosek

Matt Martz

unread,
Dec 3, 2013, 2:04:38 PM12/3/13
to ansible...@googlegroups.com, Grzegorz Nosek
I believe this has already been mentioned in a ticket recently.  Perhaps this comment: https://github.com/ansible/ansible/issues/5115#issuecomment-29583941
-- 
Matt Martz
ma...@sivel.net
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

anatoly techtonik

unread,
Dec 5, 2013, 12:41:56 PM12/5/13
to ansible...@googlegroups.com, Grzegorz Nosek
Made pull request to fix that.

Michael DeHaan

unread,
Dec 5, 2013, 3:48:34 PM12/5/13
to ansible...@googlegroups.com, Grzegorz Nosek
The code behavior should not change here, we just want to clarify docs.

-- Michael

anatoly techtonik

unread,
Dec 6, 2013, 2:22:47 AM12/6/13
to ansible...@googlegroups.com, Grzegorz Nosek
I am sure the docs are right. Reading ansible.cfg from playbook.yml
directory is intuitive and valid. It is much better than reading
playbooks from random dir. I can easily imagine my IDE to be set to
the wrong working directory with ansible.cfg inside. I'd hate to debug
this issue.
--
anatoly t.
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/nYZlptv4KZc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to

Michael DeHaan

unread,
Dec 6, 2013, 7:55:56 AM12/6/13
to ansible...@googlegroups.com, Grzegorz Nosek
I understand your complaint, however, the docs aren't right because they don't match the code.

We will not be breaking existing users by changing this.

What you should do of course is put your ansible.cfg in the user specific location or the global location, and not use the other if you do not
like that behavior.

People keep playbooks in various directories of their repo and it does not make sense.

pb/site.yml
pb/other/include.yml

And may run them from *both* places, and in which case the latter would not find ansible.cfg

The code is correct and will not be changing, I'd suggest, again, not using this behavior if you don't like it.


Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

anatoly techtonik

unread,
Dec 6, 2013, 10:15:37 AM12/6/13
to ansible...@googlegroups.com, Grzegorz Nosek
On Fri, Dec 6, 2013 at 3:55 PM, Michael DeHaan <mic...@ansibleworks.com> wrote:
> I understand your complaint, however, the docs aren't right because they
> don't match the code.
>
> We will not be breaking existing users by changing this.
>
> What you should do of course is put your ansible.cfg in the user specific
> location or the global location, and not use the other if you do not
> like that behavior.
>
> People keep playbooks in various directories of their repo and it does not
> make sense.
>
> pb/site.yml
> pb/other/include.yml
>
> And may run them from *both* places, and in which case the latter would not
> find ansible.cfg

Which case are speaking about - current or proposed?

> The code is correct and will not be changing, I'd suggest, again, not using
> this behavior if you don't like it.

Have you considered my case in addition to existing lookup logic?

--
anatoly t.
Reply all
Reply to author
Forward
0 new messages