Unable to parse ansible/contrib/inventory/ec2.py as an inventory source

111 views
Skip to first unread message

hegui...@gmail.com

unread,
Oct 22, 2018, 9:42:29 PM10/22/18
to Ansible Project
When I run the following command in the directory ansible/contrib/inventory
ansible -i ec2.py all -m ping
and I got the following error:
[WARNING]:  * Failed to parse /Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py with
ini plugin: /Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py:3: Error parsing host
definition ''''': No closing quotation

 [WARNING]: Unable to parse /Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py as an
inventory source

 [WARNING]: No inventory was parsed, only implicit localhost is available

 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

My OS is MacOS and ansible version is 2.6.1. Did something or configurations be lost?

Vladimir Botka

unread,
Oct 23, 2018, 2:08:17 AM10/23/18
to Ansible Project
Odd number of the quotation marks caused the error. Fix line 3 in ec2.py

Kai Stian Olstad

unread,
Oct 23, 2018, 2:19:45 AM10/23/18
to ansible...@googlegroups.com
On 23.10.2018 03:42, hegui...@gmail.com wrote:
> When I run the following command in the directory
> ansible/contrib/inventory
>
> ansible -i ec2.py all -m ping
>
> and I got the following error:
>
> [WARNING]: * Failed to parse
> /Users/hehe/Projects/python/ansible/contrib/inventory/ec2.py with ini
> plugin:

Ansible is trying to read the content instead of executing the script
because of missing execution bit.
So you need to set the execution bit on ec2.py to make it work.

--
Kai Stian Olstad

hegui...@gmail.com

unread,
Oct 23, 2018, 3:02:06 AM10/23/18
to Ansible Project
HI Kai, thanks for your feedback. I referred to the docs: https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html. Is it correct?

Guimin He

在 2018年10月23日星期二 UTC+8下午2:19:45,Kai Stian Olstad写道:

Dick Visser

unread,
Oct 23, 2018, 4:15:57 AM10/23/18
to ansible...@googlegroups.com
On Tue, 23 Oct 2018 at 09:02, <hegui...@gmail.com> wrote:
>
> HI Kai, thanks for your feedback. I referred to the docs: https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html. Is it correct?

Yes, it actually says so:

'The easiest is to use Ansible’s -i command line option and specify
the path to the script after marking it executable:'


Dick

hegui...@gmail.com

unread,
Oct 23, 2018, 11:25:13 AM10/23/18
to Ansible Project
HI Dick, thanks for your feedback. I know this docs and the command, but this command can not work. I want to know the error reason and how I should do?

在 2018年10月23日星期二 UTC+8下午4:15:57,Dick Visser写道:

Oriol Tauleria

unread,
Oct 24, 2018, 3:22:26 AM10/24/18
to ansible...@googlegroups.com
Hi Kai,

Error origin:
The file you have downloaded is not marked as executable, so when you pass as inventory file, Ansible tries to read (not to execute it).
Ansible tries to read as "ini" file (you have the first warning) but, of course, this is not an ini file so it raises the warning.

Solution:
As Dick suggest, you need to mark as executable the script  (chmod +x ec2.py) and launch again the ansible command (ansible -i ec2.py all -m ping).

Have you tried this solution?




--
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/0af65ca9-ec45-4b05-b207-603b618c0092%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kai Stian Olstad

unread,
Oct 24, 2018, 3:43:18 AM10/24/18
to ansible...@googlegroups.com
On 24.10.2018 09:22, Oriol Tauleria wrote:
> Hi Kai,
>
> Error origin:
> The file you have downloaded is not marked as executable, so when you
> pass
> as inventory file, Ansible tries to read (not to execute it).

You need to read the whole thread, I'm not the one with the problem.
I actually wrote the same solution that you write here to the OP.

--
Kai Stian Olstad

Oriol Tauleria

unread,
Oct 24, 2018, 5:15:09 AM10/24/18
to ansible...@googlegroups.com
Hi! 
Kai sorry for my confusion with the names.
I answering the OP (he requested more information again).
Sorry again!



--
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.

hegui...@gmail.com

unread,
Oct 24, 2018, 8:02:21 AM10/24/18
to Ansible Project
Hi Oriol, Can you give me some suggestions about this problems? Thanks in advance.

在 2018年10月24日星期三 UTC+8下午5:15:09,Oriol Tauleria写道:

Dick Visser

unread,
Oct 24, 2018, 2:17:38 PM10/24/18
to ansible...@googlegroups.com
On Wed, 24 Oct 2018 at 14:02, <hegui...@gmail.com> wrote:
>
> Hi Oriol, Can you give me some suggestions about this problems? Thanks in advance.

So far 3 different people have given you such suggestions.
Please carefully read them.

Not much use in asking a 4th time...

Dick
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1d13be84-fd65-42f3-a749-2c9f65c04371%40googlegroups.com.

she...@redhat.com

unread,
Oct 26, 2018, 10:03:34 AM10/26/18
to Ansible Project
Have you posted all the warnings provided? If so, it looks like you've disabled the script plugin, which is necessary to parse the contrib scripts. Check your ansible.cfg [inventory] enable_plugins section and the ANSIBLE_INVENTORY_ENABLED environment var.

If you just left out some of the warnings, examine the one that starts with `[WARNING]:  * Failed to parse /path/to/ec2.py with script plugin:` to see what's wrong. You can debug with `ansible-inventory -i ec2.py --graph` and by running the script alone `python ec2.py`.
Reply all
Reply to author
Forward
0 new messages