Re: [ansible-project] Dynamic Inventory does not work: it gets interpreted as .ini

87 views
Skip to first unread message

Paul Durivage

unread,
Jun 11, 2014, 3:15:42 PM6/11/14
to ansible...@googlegroups.com
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 <mas...@gmail.com> 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, and according to the example there.

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.

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 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/852a9e3f-afdc-46af-839b-361699422e23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages