Running Ansible on remote hosts without Python

Ansible is easy to use on hosts with Python. However, what happens when the target host does not have Python installed.

raw module

The raw module allows Ansible to execute low level SSH commands.

This module does not require python on the remote system, much like the script module.

So for example here is a shell command to execute a command over SSH.

ssh $ssh_uid@$target_host "df -kh"

Using the raw module of Ansible

- name: "Get disk space"
  raw: df -kh
  register: raw_diskspace

Note

If using raw from a playbook, you may need to disable fact gathering using gather_facts: no if you’re using raw to bootstrap python onto the machine.

More details on the raw module is available from the official documentation.

https://docs.ansible.com/ansible/latest/modules/raw_module.html

Last updated on 29 Sep 2019
Published on 29 Sep 2019