• +43 660 1453541
  • contact@germaniumhq.com

Bootstrapping Non-Python Hosts With Ansible


Bootstrapping Non-Python Hosts With Ansible

Ansible is an agent-less configuration management system. While agent-less it’s true, it still needs two things for it to operate: SSH and python. But what if on the brand new instance we only have SSH access, but no python? Is there a way to install python with Ansible?

Yup, and it’s fantastically easy:

- name: Install python2.7 so we can run ansible
  hosts: all
  become: True
  gather_facts: False
  tasks:
    - name: install python + aptitude
      raw: |
        apt update -y && \
        apt install -y python-minimal aptitude python-pip

The key things are:

  1. gather_facts to be false. Filling in the facts variables from the remote hosts would be executed using python.

  2. use the raw module, that executes the command, no questions asked.

This approach has the advantage of still using the Ansible inventory that defines our hosts.