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>pull/4344/head
parent
2fdf7316a4
commit
d3fa3c2d72
|
@ -1,27 +1,57 @@
|
||||||
---
|
---
|
||||||
- name: check for python
|
- name: check for python
|
||||||
stat:
|
stat:
|
||||||
path: /usr/bin/python
|
path: "{{ item }}"
|
||||||
ignore_errors: yes
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
register: systempython
|
register: systempython
|
||||||
|
with_items:
|
||||||
|
- /usr/bin/python
|
||||||
|
- /usr/bin/python3
|
||||||
|
|
||||||
- name: install python for debian based systems
|
- block:
|
||||||
raw: apt-get -y install python-simplejson
|
- name: check for dnf-3 package manager (RedHat/Fedora/CentOS)
|
||||||
ignore_errors: yes
|
raw: stat /bin/dnf-3
|
||||||
register: result
|
changed_when: false
|
||||||
when: systempython.stat is undefined or not systempython.stat.exists
|
failed_when: false
|
||||||
until: result is succeeded
|
register: stat_dnf3
|
||||||
|
|
||||||
- name: install python for fedora
|
- name: check for yum package manager (RedHat/Fedora/CentOS)
|
||||||
raw: dnf -y install python3; ln -sf /usr/bin/python3 /usr/bin/python creates=/usr/bin/python
|
raw: stat /bin/yum
|
||||||
ignore_errors: yes
|
changed_when: false
|
||||||
register: result
|
failed_when: false
|
||||||
when: systempython.stat is undefined or not systempython.stat.exists
|
register: stat_yum
|
||||||
until: (result is succeeded) and ('Failed' not in result.stdout)
|
|
||||||
|
|
||||||
- name: install python for opensuse
|
- name: check for apt package manager (Debian/Ubuntu)
|
||||||
raw: zypper -n install python-base creates=/usr/bin/python2.7
|
raw: stat /usr/bin/apt-get
|
||||||
ignore_errors: yes
|
changed_when: false
|
||||||
register: result
|
failed_when: false
|
||||||
when: systempython.stat is undefined or not systempython.stat.exists
|
register: stat_apt
|
||||||
until: result is succeeded
|
|
||||||
|
- 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