From 1c458c24a904b9f54ebf026d7227c801f22f49dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Nasiadka?= Date: Mon, 14 Dec 2020 16:54:34 +0100 Subject: [PATCH] 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 --- ansible/kayobe-ansible-user.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ansible/kayobe-ansible-user.yml b/ansible/kayobe-ansible-user.yml index cf8d161f2..f4c9da852 100644 --- a/ansible/kayobe-ansible-user.yml +++ b/ansible/kayobe-ansible-user.yml @@ -34,6 +34,24 @@ attempting bootstrap 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 hosts: kayobe_user_bootstrap_required_True gather_facts: false