代码拉取完成,页面将自动刷新
---
- 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'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。