Test Ansible on Docker and confirm python is needed

Test Ansible on Docker and confirm python is needed

Ansible can be run agentless, but python is required on the target node.

Let’s try it on Docker to see if that is true.

The code can be found in Git.


Master node which is installed Ansible run the playbook and send execution order to target machine(container).

Note that ubuntu without python will fail to run.

Since ubuntu uses Apt as its package manager, and Apt is not dependent on python, we can uninstall python.

How to run

1.Start Docker containter

2.Connect to Ansible container via SSH

3.Confirm SSH connection to targets.

1. Connect to centos, ubuntu

2. Connect to ubuntu without python


Execute ansible command to target node.


5.Check log(fail if no python environment)

As shown in the line 9 at the log, Ubuntu without python could not execute playbook.



6.Connect to target-centos, target-ubuntu again to check wheather targets, centos, ubuntu file is added or not

Explanation about Ansible

about Inventory file

The configuration is nested in this way.

About Playbook file

create file on machines(targets, centos and ubuntu)

The reason why execution was failed without python

The master node where Ansible is installed passes the python executable to the control node to be executed at runtime.

So control nodes without python will fail to execute.

Please be careful when using Ansible on network devices where python cannot be installed.


We have run Ansible using Docker and confirmed that it does not work without python.

Learn more about encryption using Ansible vault.

Translated with www.DeepL.com/Translator (free version)