Add ensure-python task

Ubuntu hosts come often without python preinstalled, this task ensures
python gets installed with raw: module on hosts missing it.

Change-Id: I8c5561b2997b5bcb3957e7d52f2b298d8a72a80d
This commit is contained in:
Michał Nasiadka 2020-12-14 16:54:34 +01:00 committed by Michal Nasiadka
parent d169b4f5c7
commit 1c458c24a9

View File

@ -34,6 +34,24 @@
attempting bootstrap attempting bootstrap
when: ssh_result.rc != 0 when: ssh_result.rc != 0
- name: Ensure python is installed
hosts: kayobe_user_bootstrap_required_True
gather_facts: no
vars:
ansible_user: "{{ bootstrap_user }}"
tags:
- ensure-python
tasks:
- name: Check if python is installed
raw: test -e /usr/bin/python3
changed_when: false
failed_when: false
register: check_python
- name: Ensure python is installed
raw: test -e /usr/bin/apt && (sudo apt -y update && sudo apt install -y python3-minimal) || (sudo dnf -y install python3)
when: check_python.rc != 0
- name: Ensure the Kayobe Ansible user account exists - name: Ensure the Kayobe Ansible user account exists
hosts: kayobe_user_bootstrap_required_True hosts: kayobe_user_bootstrap_required_True
gather_facts: false gather_facts: false