Sobes.tech
Junior — Middle

How can you use Ansible on a system where Python is not installed?

sobes.tech AI

Answer from AI

Ansible by default requires Python on the target machine to execute modules. If Python is absent, several approaches can be used:

  1. Using raw modules — commands are executed directly via SSH without Python.
  2. Using Ansible with support for Python 3 or without Python (for example, with Ansible 2.8+ using the parameter ansible_python_interpreter=/bin/sh) — but this is limited.
  3. Using Ansible with the raw module to install Python on the target system before executing other tasks.

Example of installing Python via raw:

- hosts: servers
  tasks:
    - name: Install Python
      raw: yum install -y python3
    - name: Run regular tasks
      command: echo "Python installed"

Thus, without Python, you can temporarily use the raw module to prepare the system, after which Ansible can operate normally.

How can you use Ansible on a system where Python is… - sobes.tech