chmod +x host.py

Ansible uses the executable flag to determine whether or not a file is a
.ini or script.


On Wed, Jun 11, 2014 at 11:21 AM, Pierre Masci <[email protected]> wrote:

> Hi,
>
> I'm trying to get the simplest *Dynamic Inventory* to work, but it
> doesn't work because *Ansible interprets it as .ini* :
>
>     $ ansible-playbook -i hosts.py play.yml
>     ERROR: *Invalid ini entry*: sys - need more than 1 value to unpack
>
> Here is the code in *host.py*:
>
> import sys
>
> if len(sys.argv) == 2 and (sys.argv[1] == '--list'):
>     print """{
>     'local': ['127.0.0.1'],
> }"""
> elif len(sys.argv) == 3 and (sys.argv[1] == '--host'):
>     print '{}'
> else:
>     print "Usage: %s --list or --host <hostname>" % sys.argv[0]
>     sys.exit(1)
>
>
> I can run it and I am pretty sure that it returns what it should, as
> presented in the documentation
> <http://docs.ansible.com/developing_inventory.html>, and according to the
> example there
> <http://jpmens.net/2013/06/18/adapting-inventory-for-ansible/>.
>
> For the playbook, I'm also using the simplest possible. Here is *play.yml*
> :
>
> - hosts: all
>   connection: local
>   tasks:
>     - name: Can I run this playbook?
>       debug: msg="Yes!"
>
> *It runs properly* when I don't use the host.py file:
>
> $ ansible-playbook -i 127.0.0.1, play.yml
> [ output not copied here - it's all fine ! ]
>
> (note the comma, which enables to run a playbook by directly indicating a
> host's address, as per here
> <http://stackoverflow.com/questions/17188147/how-to-run-ansible-without-specifying-the-inventory-but-the-host-directly>
> .
>
> I'm stuck there.
> *Any idea what I'm doing wrong?*
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/852a9e3f-afdc-46af-839b-361699422e23%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/852a9e3f-afdc-46af-839b-361699422e23%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAK6JQEHkuvQ78fVp78SSi3Qtk5h%2BH-7umemkvJ2YzJTEg25QKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to