mirror of https://github.com/ceph/ceph-ansible.git
refact python installation
This commit refacts the python installation when no available.
In order to avoid generating errors, we check for each package manager
to detect which system we are running on.
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit d3fa3c2d72
)
pull/4348/head
parent
0f90ffe9df
commit
4b2d13995d
|
@ -1,27 +1,57 @@
|
|||
---
|
||||
- name: check for python
|
||||
stat:
|
||||
path: /usr/bin/python
|
||||
ignore_errors: yes
|
||||
path: "{{ item }}"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: systempython
|
||||
with_items:
|
||||
- /usr/bin/python
|
||||
- /usr/bin/python3
|
||||
|
||||
- name: install python for debian based systems
|
||||
raw: apt-get -y install python-simplejson
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
when: systempython.stat is undefined or not systempython.stat.exists
|
||||
until: result is succeeded
|
||||
- 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: install python for fedora
|
||||
raw: dnf -y install python3; ln -sf /usr/bin/python3 /usr/bin/python creates=/usr/bin/python
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
when: systempython.stat is undefined or not systempython.stat.exists
|
||||
until: (result is succeeded) and ('Failed' not in result.stdout)
|
||||
- name: check for yum package manager (RedHat/Fedora/CentOS)
|
||||
raw: stat /bin/yum
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: stat_yum
|
||||
|
||||
- name: install python for opensuse
|
||||
raw: zypper -n install python-base creates=/usr/bin/python2.7
|
||||
ignore_errors: yes
|
||||
register: result
|
||||
when: systempython.stat is undefined or not systempython.stat.exists
|
||||
until: result is succeeded
|
||||
- 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 (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 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)
|
Loading…
Reference in New Issue