install_python

Python Installer Ansible Role



Ansible role for installing python 2 or 3 using raw module on the remote host that does not have python installed yet.

Introduction

If python is not installed on the host, most of Ansible's functionality and modules aren't available. For example modules like yum, apt and set_fact rely on python being already installed. This module takes advantage of the raw module to detect and install python.

Ansible

This role was tested against Ansible version 2.7 2.8 2.9 2.10 . The supported platforms are

  • Debian
    • buster
    • stretch
  • Ubuntu
    • focal
    • bionic
    • xenial
  • Centos
    • 8
    • 7

Variables

There is only one variable called install_python_package:

install_python_package: python3

For python2 however, since the package names vary, the following are suggested:

group_vars:
  all:
    install_python_package: python2
host_vars:
  stretch:
    install_python_package: python
  bionic:
    install_python_package: python
  xenial:
    install_python_package: python

Example

# inventory
[servers]
focal.example.com install_python_package=python2
stretch.example.com install_python_package=python
# playbook.yml
- hosts: servers
  gather_facts: no
  roles:
    - mariancraciun1983.install_python
# install the role
ansible-galaxy install mariancraciun1983.install_python
# run the playbook
ansible-playbook -i inventory playbook.yml

License

MIT License

About

Install python 2 or 3 using the raw module where the remote system has no python installed

Install
ansible-galaxy install mariancraciun1983/ansible-install-python
GitHub repository
License
mit
Downloads
921
Owner
¯\_(ツ)_/¯