Created
June 16, 2016 21:59
-
-
Save gwillem/4ba393dceb55e5ae276a87300f6b8e6f to your computer and use it in GitHub Desktop.
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this snippet to the top of your playbook. | |
# It will install python2 if missing (but checks first so no expensive repeated apt updates) | |
# gwillem@gmail.com | |
- hosts: all | |
gather_facts: False | |
tasks: | |
- name: install python 2 | |
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) |
PS I think bootstrapping a Python 2 installation is now likely to be unnecessary, since Ansible 2.8+ will auto-detect a suitable Python interpreter to use anyway.
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html
If anyone is looking for a solution for Ubuntu 20.04 - change python-minimal
to python2-minimal
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep, I think it's simply that a target server without python installed, is unable to run normal ansible task steps. Using 'raw' side-steps the need for python.