dominis / ansible-shell Goto Github PK
View Code? Open in Web Editor NEWInteractive ansible shell
License: GNU General Public License v3.0
Interactive ansible shell
License: GNU General Public License v3.0
# netscaler name=${facter_fqdn}:8080 action=enable
# mysql_user user=bob password=12345 priv=*.*:ALL state=present
Ansible verison: Ansible 1.8
After ansible 1.8 version has cancel the library_path vaule at ansible.cfg.
at ansible-shell interaction model not display ansible module when I type TAB.
[root@vm10-160-112-18 ansible-shell]# ansible --version ansible 1.9.1 configured module search path = None
root@* (10)[f:10]$ help copy Traceback (most recent call last): File "/usr/bin/ansible-shell", line 378, in AnsibleShell(options, args).cmdloop() File "/usr/bin/ansible-shell", line 136, in cmdloop cmd.Cmd.cmdloop(self) File "/usr/lib64/python2.7/cmd.py", line 142, in cmdloop stop = self.onecmd(line) File "/usr/lib64/python2.7/cmd.py", line 221, in onecmd return func(arg) File "/usr/lib64/python2.7/cmd.py", line 311, in do_help func() File "/usr/bin/ansible-shell", line 88, in setattr(self, 'help_' + module, lambda module=module: self.helpdefault(module)) File "/usr/bin/ansible-shell", line 332, in helpdefault oc, a = ansible.utils.module_docs.get_docstring(in_path) ValueError: too many values to unpack
This doesn't work as I expected:
# ansible-shell -i inventories/ec2/
Traceback (most recent call last):
File "/usr/local/bin/ansible-shell", line 33, in <module>
class AnsibleShell(cmd.Cmd):
File "/usr/local/bin/ansible-shell", line 35, in AnsibleShell
ansible = ansible.runner.Runner()
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 178, in __init__
self.inventory = utils.default(inventory, lambda: ansible.inventory.Inventory(host_list))
File "/Library/Python/2.7/site-packages/ansible/utils/__init__.py", line 833, in default
return function()
File "/Library/Python/2.7/site-packages/ansible/runner/__init__.py", line 178, in <lambda>
self.inventory = utils.default(inventory, lambda: ansible.inventory.Inventory(host_list))
File "/Library/Python/2.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 ?
Same error for:
# ansible-shell -i ./<directory>/ec2.py
These inventory args do work with plain ansible
:
# ansible '*' -i ./inventories/ec2 --list-hosts | wc -l
124
# ansible '*' -i ./inventories/ec2/ec2.py --list-hosts | wc -l
124
?
Attempting to use ansible-shell for versions greater than 1.4.5 (i.e. 1.5.3 or devel) causes all of the modules to be unavailable.
In ansible, it is possible to specify target hosts via a variety of joins, intersections, and excludes of multiple groups/hosts (http://docs.ansible.com/intro_patterns.html). Any chance some of this can be added to ansible-shell?
It comes up quite often for me that I want to target only servers that are both in the "production" and "web" groups, or perhaps in the "dev" group but NOT in the "inactive" group. In ansible, this is as simple as:
ansible prod:&web -m lineinfile -a "[...]"
ansible dev:!inactive -m fetch -a "[...]"
... but unfortunately, it seems ansible-shell doesn't support such functionality (or at least not that I can find).
I'm a fan of ansible-shell and I would like to package it for Fedora and Fedora EPEL but the Fedora packaging guidelines require a license be provided (and that the license comply with the list of acceptable licenses).
Would you consider selecting an open source license for ansible-shell?
Thank you,
-AdamM
save history to a file (~/.ansible-shell.hist) and inject it back on start
root@lixia:~/soft/ansible-shell# ansible-shell
Traceback (most recent call last):
File "/usr/local/bin/ansible-shell", line 4, in <module>
__import__('pkg_resources').run_script('ansible-shell==0.0.5', 'ansible-shell')
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 719, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1511, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/ansible_shell-0.0.5-py2.7.egg/EGG-INFO/scripts/ansible-shell", line 36, in <module>
ImportError: No module named runner
root@lixia:~/soft/ansible-shell#
Hi, could you push a new release to PyPI when you get a chance? The one currently there is old and crashes on startup.
Hi, Nandor
there is a bug on column calculation in-python readline if use color prompt(bug#17337):
With a prompt that uses ANSI color escape codes, python3 input() and python2 raw_input() behave incorrectly when it comes to the wrapping of the first line - almost certainly due to the wrong string length calculation.
The line breaking occurs k characters early, where k is the number of characters in the ANSI escape sequence.
Even worse, the line break does not switch to the next line, but instead jumps back to the beginning, overwriting the prompt and the previously written input.
our shell also have this problem(python's cmd module use it as the default input reader):
I have tried the "bugfix solution"(http://stackoverflow.com/questions/9468435/look-how-to-fix-column-calculation-in-python-readline-if-use-color-prompt) by change color.py in ansible, the bad news is: it still not works good.
so as a work around, should we turn off the prompt color(or leave it as another option...)?
My understanding is that ansible-shell some-pattern
should launch a shell that only runs commands on hosts matching that pattern; however, it seems to still run commands against all hosts.
From a very brief glance over the code, it looks like this information is just ignored and never picked up during the argument parsing.
I've closed the Review Request for the Fedora package that I filed as a result of my previous issue, after a thread of discussion on Twitter it was decided it would be better if we could get ansible-shell into mainline ansible. I wanted to know if this is something you would be interested in doing? If not, if you mind if I do?
For background, this is the conversation that happened on Twitter:
https://twitter.com/TheMaxamillion/status/469823014033309697
Thank you,
-AdamM
All modules in ansible-shell doesn't print any results:
=8<=========================================
teer@teer ~ $ansible local -m ping
localhost | success >> {
"changed": false,
"ping": "pong"
}
teer@teer ~ $ansible-shell
Welcome to the ansible-shell.
Type help or ? to list commands.
root@/[s:2]$ cd local
root@/local (1)[s:2]$ ping
root@/local (1)[s:2]$
=8<=========================================
ansible-shell from git commit d1a8492, ansible-1.3.2 (tag v1.3.2/9d5d88b59fa3fdbbec4f4cb269c446c666e3abbb) from official ansible's git.
Ansible 2.0 just dropped this week. With it, I get this error:
[$]> ansible-shell
Traceback (most recent call last):
File "/usr/bin/ansible-shell", line 36, in <module>
import ansible.runner
ImportError: No module named runner
I don't see any mention of a re-org of runner
in the changelog, but it has definitely moved (or disappeared).
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.
ansible-shell --inventory-file ./inventory/ --vault-password-file .vault_pass.txt
(...)
raise errors.AnsibleError("A vault password must be specified to decrypt %s" % path)
ansible.errors.AnsibleError: A vault password must be specified to decrypt /home/stephane/Documents/devel/ansible-stephane.pyenv/ansible/inventory/group_vars/all/secret.yml
But it works with --ask-vault-pass parameter
Regards.
Sounds like a great idea. However, I'm getting this error when just calling ansible-shell from my Ubuntu bash:
Traceback (most recent call last):
File "/usr/local/bin/ansible-shell", line 180, in
AnsibleShell().cmdloop()
File "/usr/local/bin/ansible-shell", line 26, in init
self.set_prompt()
File "/usr/local/bin/ansible-shell", line 44, in set_prompt
self.prompt = stringc(os.getlogin() + '@/' + self.cwd, 'green')
OSError: [Errno 2] No such file or directory
At the README you stated that the functionality of this application will be available at ansible 2.1 but I can't find anything regarding that. I know that one can execute ansible modules via command line but that's not as convenient as your application.
Can you give any hints regarding that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.