ceph-ansible/raw_install_python.yml

59 lines
1.7 KiB
YAML

---
- name: check for python
stat:
path: "{{ item }}"
changed_when: false
failed_when: false
register: systempython
with_items:
- /usr/bin/python
- /usr/bin/python3
- /usr/libexec/platform-python
- block:
- name: check for dnf-3 package manager (RedHat/Fedora/CentOS)
raw: stat /bin/dnf-3
changed_when: false
failed_when: false
register: stat_dnf3
- name: check for yum package manager (RedHat/Fedora/CentOS)
raw: stat /bin/yum
changed_when: false
failed_when: false
register: stat_yum
- name: check for apt package manager (Debian/Ubuntu)
raw: stat /usr/bin/apt-get
changed_when: false
failed_when: false
register: stat_apt
- name: check for zypper package manager (SUSE/OpenSUSE)
raw: stat /usr/bin/zypper
changed_when: false
failed_when: false
register: stat_zypper
- name: install python for RedHat based OS - dnf
raw: >
{{ 'dnf' if stat_dnf3.rc == 0 else 'yum' }} -y install python3;
ln -sf /usr/bin/python3 /usr/bin/python
creates=/usr/bin/python
register: result
until: (result is succeeded) and ('Failed' not in result.stdout)
when: stat_dnf3.rc == 0 or stat_yum.rc == 0
- name: install python for debian based OS
raw: apt-get -y install python-simplejson
register: result
until: result is succeeded
when: stat_apt.rc == 0
- name: install python for SUSE/OpenSUSE
raw: zypper -n install python-base
register: result
until: result is succeeded
when: stat_zypper.rc == 0
when: not True in (systempython.results | selectattr('stat', 'defined') | map(attribute='stat.exists') | list | unique)