-
Notifications
You must be signed in to change notification settings - Fork 1k
/
raw_install_python.yml
69 lines (61 loc) · 2.05 KB
/
raw_install_python.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
- 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)
- name: install python-xml for opensuse only if python2 is installed already
raw: zypper -n install python-xml
register: result
until: result is succeeded
with_items: "{{ systempython.results }}"
when:
- stat_zypper.rc is defined
- stat_zypper.rc == 0
- item.stat.exists | bool
- item.stat.path == '/usr/bin/python'