Raw module + no JSON needed for copy/file/template

1,243 views
Skip to first unread message

Michael DeHaan

unread,
May 5, 2012, 12:54:31 PM5/5/12
to ansible...@googlegroups.com
Two new things on the devel branch of interest to people with EL 5
hosts, or anywhere else where Python isn't 2.5 yet.

(1)

The raw module, added by Adrià Casajús, has been merged in. This
allows direct SSH communication with hosts without using an Ansible
module, and is of course therefore reliant on the user's shell and so
forth.

This is primarily usable in the case where you have a RHEL5/CentOS 5
host and want to use Ansible with it. Before you can run a playbook
you could fix them up like so:

ansible all -m raw -a "yum install python-simplejson"

It's also useful for talking to routers and load balancers or whatever
that don't have Python installed.

(2)

The template, copy, and file modules can all now work without any JSON
dependencies.

If you need to set up EPEL first to get python-simplejson, you can
also use the 'template' or 'copy' modules now first, because the file
module no longer requires any JSON. I think that's pretty awesome, as
we're now self bootstrapping for legacy hosts!

ansible all -m copy -a "src=/wherever/epel.repo dest=/etc/yum.repos.d/epel"
ansible all -m raw - a "yum install python-simplejson"

Docs section on this coming soon.

Generally any module that does not need to return simple json can be
made to not have a dependency on JSON, but it's WAY too useful to be
able to return complex data such that I don't intend to really port
any additional modules to work this way. This is primarily there as
instructions on how to get old hosts ready to use Ansible, and we'll
document it that way.

Michael DeHaan

unread,
Aug 8, 2012, 1:19:03 PM8/8/12
to ansible...@googlegroups.com
It's not going to be reverted, however, you can easily use the raw module to run commands, which goes straight in through SSH without any module calls.    This way you don't need to use
copy to configure the repo either. 

ansible -m raw -a "yum install http://path/to/python-simplejson.rpm"


On Wednesday, August 8, 2012 at 12:07 PM, Jonathan Kim wrote:
Hi, 

I'm new to Ansible but have been really impressed with what I have seen! We unfortunately have a lot of legacy servers in the company I am working for and a lot of them don't have simplejson so I was very happy to see that the copy module doesn't use it so that they can be easily bootstrapped. However on the 0.6 release it looks like the copy module does require simplejson on the remote server which means I've had to revert back to the 0.5 version for the moment. Not quite sure exactly when this changed occurred but can it be reverted as it would really help with maintaining old servers?

Thanks, 
Jonathan

Jonathan Kim

unread,
Aug 9, 2012, 1:47:09 PM8/9/12
to ansible...@googlegroups.com
OK fair enough!

Michael DeHaan

unread,
Dec 16, 2012, 2:02:55 PM12/16/12
to ansible...@googlegroups.com
You can use /usr/bin/ansible with -m raw and that is basically it.

On Wed, Dec 12, 2012 at 12:39 AM, Ser Heang Tan <serh...@gmail.com> wrote:
> Hi guys,
> I know this is an old topic, but I would like to use ansible just with ssh,
> since I got a lot of old boxes that cannot be install with new python nor
> simplejson, and a few network devices that only have basic ssh and shell
> available. How can I archive this with ansible?
>
> Thank you.
> --
>
>

ankit tyagi

unread,
Dec 18, 2014, 12:11:24 AM12/18/14
to ansible...@googlegroups.com
I'm able to run the raw module using Ansible ad-hoc commands however, when run the playbook with same commands it fails with error:
"invalid output was: Traceback (most recent call last):
  File "/tmp/ansible-tmp-1418879078.47-138258829915016/setup", line 187, in <module>
    import locale
ImportError: No module named locale "

Any idea what I might be missing....or how how should I write the playbook to reflect the same as I'm doing in ad-hoc command.

My ad-hoc command is: "sudo ansible locale1 -i data --private-key=server.pem -vvvv -u ubuntu -m script -a multivr.sh "

Where miltivr.sh is a small script in bash that removes the multiverse.list.
locale1 is a tag in my inventory file to tell ansible which hosts I need to run this command on.

Any help would be appreciated.
Reply all
Reply to author
Forward
0 new messages