Hello Guys,
I’m using ansible cli a lot for my daily work to run commands simultaneously on our cluster. Mainly I’m using the shell module but sometimes easier to use the specified module for a job. However I always forgot the required arguments, even for the ones created by me. The other thing I always forgot is the group names in our hosts file.
So I’ve created a little interactive shell for ansible. It can complete the host names, host groups, module names and its arguments.
By default it’s using the shell if there is no matching module and there are three built in commands:
- cd - change to host/group
- serial - change the number of forks
- list - list the nodes in the current group
You can download from: https://github.com/dominis/ansible-shell
At this point there is no installer just drop the file somewhere to your path and run it.
[root@cobbler dominis]# ansible-shell
Welcome to the ansible-shell.
Type help or ? to list commands.
dominis@/[s:2]$ cd app
app-pool app02.bfc.kinja.com app04.bfc.kinja.com app06.bfc.kinja.com app08.bfc.kinja.com app10.bfc.kinja.com app12.bfc.kinja.com
app01.bfc.kinja.com app03.bfc.kinja.com app05.bfc.kinja.com app07.bfc.kinja.com app09.bfc.kinja.com app11.bfc.kinja.com
dominis@/[s:2]$ cd app-pool
dominis@/app-pool (12)[s:2]$ ec2
ec2 ec2_facts ec2_vol
dominis@/app-pool (12)[s:2]$ ec2
count= ec2_secret_key= group= id= instance_tags= kernel= monitor= user_data= wait=
ec2_access_key= ec2_url= group_id= image= instance_type= key_name= ramdisk= vpc_subnet_id= wait_timeout=
dominis@/app-pool (12)[s:2]$ help ec2
create an instance in ec2, return instanceid
Paremeters:
ramdisk ramdisk I(eri) to use for the instance
kernel kernel I(eki) to use for the instance
key_name key pair to use on the instance
image I(emi) (or I(ami)) to use for the instance
vpc_subnet_id the subnet ID in which to launch the instance (VPC)
user_data opaque blob of data which is made available to the ec2 instance
wait_timeout how long before wait gives up, in seconds
ec2_url url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints)
ec2_access_key ec2 access key
ec2_secret_key ec2 secret key
id identifier for this instance or set of instances, so that the module will be idempotent with respect to EC2 instances.
wait wait for the instance to be in state ‘running’ before returning
count number of instances to launch
group security group to use with the instance
monitor enable detailed monitoring (CloudWatch) for instance
instance_type instance type to use for the instance
instance_tags a hash/dictionary of tags to add to the new instance; ‘{“key”:“value”}’ and ‘{“key”:“value”,“key”:“value”}’
group_id security group id to use with the instance
dominis@/app-pool (12)[s:2]$ serial 12
dominis@/app-pool (12)[s:12]$ ping
app12.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app04.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app07.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app06.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app08.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app10.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app11.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app09.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app05.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app01.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app03.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
app02.bfc.kinja.com
{‘invocation’: {‘module_name’: ‘ping’, ‘module_args’: ‘’}, u’changed’: False, u’ping’: u’pong’}
dominis@/app-pool (12)[s:12]$ date
app12.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app04.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app07.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app06.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app08.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app10.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app11.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app09.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app05.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app01.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app03.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
app02.bfc.kinja.com
Fri Jun 7 17:46:40 EDT 2013
Enjoy,
Nandi