December 2018
Beginner
826 pages
22h 54m
English
Like raw, you can pass native commands to a remote machine using Ansible (in fact, you could translate an entire bash script into an Ansible role remarkably easily), though usually this type of functionality is reserved for instances where you absolutely can't achieve what you're trying to do with dedicated Ansible modules.
These two do, however, require Python to be on the remote machine.
First, let's look at the shell module:
$ ansible -b -k -m shell -a 'whoami > BUTTER; cat BUTTER | rev' -i 192.168.33.11, 192.168.33.11SSH password: 192.168.33.11 | SUCCESS | rc=0 >>toor
Note that I'm basically running a small one-liner within my Ansible command.
Next, let's use the command module:
$ ansible -b -k -m command ...
Read now
Unlock full access