dominis/ansible-shell

Add support for vault files.

orclev opened this issue · 9 comments

When I try to run this I get the following stack dump:
Traceback (most recent call last): File "/usr/local/bin/ansible-shell", line 318, in <module> AnsibleShell(options, args).cmdloop() File "/usr/local/bin/ansible-shell", line 42, in __init__ self.ansible = ansible.runner.Runner(host_list=self.options.host_list) File "/usr/local/lib/python2.7/site-packages/ansible/runner/__init__.py", line 180, in __init__ self.inventory = utils.default(inventory, lambda: ansible.inventory.Inventory(host_list)) File "/usr/local/lib/python2.7/site-packages/ansible/utils/__init__.py", line 889, in default return function() File "/usr/local/lib/python2.7/site-packages/ansible/runner/__init__.py", line 180, in <lambda> self.inventory = utils.default(inventory, lambda: ansible.inventory.Inventory(host_list)) File "/usr/local/lib/python2.7/site-packages/ansible/inventory/__init__.py", line 139, in __init__ raise errors.AnsibleError("Unable to find an inventory file, specify one with -i ?") ansible.errors.AnsibleError: Unable to find an inventory file, specify one with -i ?

It seems like the ansible package isn't happy about something or other, but I'm not entirely sure what. This is happening on OS X, with a brew installed copy of python and ansible.

Have you provided the inventory to ansible-shell?

"R. Kyle Murphy" notifications@github.com napisał:

When I try to run this I get the following stack dump:
Traceback (most recent call last):
File "/usr/local/bin/ansible-shell", line 318, in
AnsibleShell(options, args).cmdloop()
File "/usr/local/bin/ansible-shell", line 42, in init
self.ansible = ansible.runner.Runner(host_list=self.options.host_list)
File
"/usr/local/lib/python2.7/site-packages/ansible/runner/init.py",
line 180, in init
self.inventory = utils.default(inventory, lambda:
ansible.inventory.Inventory(host_list))
File
"/usr/local/lib/python2.7/site-packages/ansible/utils/init.py",
line 889, in default
return function()
File
"/usr/local/lib/python2.7/site-packages/ansible/runner/init.py",
line 180, in
self.inventory = utils.default(inventory, lambda:
ansible.inventory.Inventory(host_list))
File
"/usr/local/lib/python2.7/site-packages/ansible/inventory/init.py",
line 139, in init
raise errors.AnsibleError("Unable to find an inventory file, specify
one with -i ?")
ansible.errors.AnsibleError: Unable to find an inventory file, specify
one with -i ?

It seems like the ansible package isn't happy about something or other,
but I'm not entirely sure what. This is happening on OS X, with a brew
installed copy of python and ansible.


Reply to this email directly or view it on GitHub:
#33

Wysłane za pomocą K-9 Mail.

How do I do that? I tried providing the -i argument it asked for, but that didn't seem to make a difference. Is there a command line help for this? Are there other options?

Edit: Got it to accept one of the inventory files I had, but now it's complaining about the vault password. I tried passing --ask-vault-pass like I do for regular ansible commands but it says that's an unknown option.

After upgrading to the latest github version I can now see a command line help, but I'm still stuck on the inability to request it prompt for a vault password.

I don't think ansible-shell currently supports vault at all. I'll see if it's hard to add

OK, I'm going to rename this issue then to more accurately reflect this most recent problem.

So, the good news is after installing your vault branch it does in fact look like it supports vault files. Awesome... unfortunately I'm getting another error which I think has to do with the way ansible gets installed by brew. Brew puts all the ansible files under /usr/local/etc/ansible which I suspect is why ansible-shell isn't able to find the inventory file in the first place. The specific error I'm getting now is

File "/usr/local/bin/ansible-shell", line 129, in list_modules
     for root, dirs, files in os.walk(C.DEFAULT_MODULE_PATH):
File "/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 278, in walk
     names = listdir(top)
TypeError: coercing to Unicode: need string or buffer, NoneType found

which if I'm reading python right means it was expecting a string and instead it got a null pointer. I'm guessing maybe C.DEFAULT_MODULE_PATH is null (NoneType) here? At the very least I'm content to call this issue closed, you added in support for vault files, but it looks like maybe there's some more systemic issues with ansible-shell on the brew version of ansible.

The issue you are talking about now is fixed in 2 different PRs (one mine, and the other from MiLk). It's a result of how Ansible 1.8 reorganised modules, and not a brew peculiarity.

The author here doesn't seem to respond to PRs lately, I'll try to contact him tomorrow. For now you can try to use my fork, I'm using it with Ansible 1.8, and it has like 3 or 4 automated tests ;-)

"R. Kyle Murphy" notifications@github.com napisał:

So, the good news is after installing your vault branch it does in fact
look like it supports vault files. Awesome... unfortunately I'm getting
another error which I think has to do with the way ansible gets
installed by brew. Brew puts all the ansible files under
/usr/local/etc/ansible which I suspect is why ansible-shell isn't able
to find the inventory file in the first place. The specific error I'm
getting now is

File "/usr/local/bin/ansible-shell", line 129, in list_modules
for root, dirs, files in os.walk(C.DEFAULT_MODULE_PATH):
File
"/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 278, in walk
names = listdir(top)
TypeError: coercing to Unicode: need string or buffer, NoneType found

which if I'm reading python right means it was expecting a string and
instead it got a null pointer. I'm guessing maybe C.DEFAULT_MODULE_PATH
is null (NoneType) here? At the very least I'm content to call this
issue closed, you added in support for vault files, but it looks like
maybe there's some more systemic issues with ansible-shell on the brew
version of ansible.


Reply to this email directly or view it on GitHub:
#33 (comment)

Wysłane za pomocą K-9 Mail.

Awesome. I managed to work around it locally by creating a .ansible.cfg in my home directory, after looking through the source code of the ansible python module.

I've got a message from dominis: he's pretty busy at the moment, but still cares about the project :-)
There's work on merging ansible-shell into Ansible: ansible/ansible#8030