Playbook look for hosts file

42 views
Skip to first unread message

Yvo van Beek

unread,
Dec 4, 2014, 12:10:06 AM12/4/14
to ansible...@googlegroups.com
Hi,

It seems common practice for playbooks to have a "hosts" file in the root of the playbook.
When you run a playbook you have to supply it via the -i parameter, otherwise you will get the error: "ERROR: Unable to find an inventory file, specify one with -i ?"

It would be nice if Ansible would automaticly detect the hosts file in the playbook folder. Less arguments would make it even easier to use.


Tomasz Kontusz

unread,
Dec 4, 2014, 12:38:11 AM12/4/14
to ansible...@googlegroups.com
I think explicitly passing in the inventory is OK: pretty soon you'll have at least two of them (staging/prod etc.), and you REALLY don't want to apply changes to the wrong set of hosts ;-)

If you still want to set a default inventory path, you can do this through ANSIBLE_HOSTS environment variable or by setting "hostfile" in ansible.cfg

Yvo van Beek <y...@codegazer.com> napisał:

--
Wysłane za pomocą K-9 Mail.

Yvo

unread,
Dec 4, 2014, 5:15:35 AM12/4/14
to ansible...@googlegroups.com
For staging you create a separate group in the same hostfile right?
And you can't name them both "hosts" :), so that shouldn't be a problem.

Tomasz Kontusz

unread,
Dec 4, 2014, 2:25:04 PM12/4/14
to ansible...@googlegroups.com, Yvo
On 04.12.2014 11:15, Yvo wrote:
For staging you create a separate group in the same hostfile right?
And you can't name them both "hosts" :), so that shouldn't be a problem.
I'm using separate inventory for staging, to be extra sure those environments don't mix. And it's actually a pretty standard practice to do so.

On Thursday, December 4, 2014 4:38:11 PM UTC+11, Tomasz Kontusz wrote:
I think explicitly passing in the inventory is OK: pretty soon you'll have at least two of them (staging/prod etc.), and you REALLY don't want to apply changes to the wrong set of hosts ;-)

If you still want to set a default inventory path, you can do this through ANSIBLE_HOSTS environment variable or by setting "hostfile" in ansible.cfg

Yvo van Beek <y...@codegazer.com> napisał:
Hi,

It seems common practice for playbooks to have a "hosts" file in the root of the playbook.
When you run a playbook you have to supply it via the -i parameter, otherwise you will get the error: "ERROR: Unable to find an inventory file, specify one with -i ?"

It would be nice if Ansible would automaticly detect the hosts file in the playbook folder. Less arguments would make it even easier to use.



--
Wysłane za pomocą K-9 Mail.
--
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.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4542e6bb-dd7a-4645-89da-1e834b394022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages