-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.yml
executable file
·52 lines (51 loc) · 2.34 KB
/
bootstrap.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
- hosts: all
gather_facts: no
become: yes
become_method: sudo
pre_tasks:
- name: when no python2, install python2 for Ansible<2.8
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) || (yum install -y python2 python-simplejson)
register: output
changed_when: output.stdout | length > 0
when:
- ansible_version.full is version_compare('2.8', '<')
- ( ansible_python_interpreter is not defined or ansible_python_interpreter == "/usr/bin/python" )
# ansible_os_family conds. cannot be used as this is before gathering facts (where ansible is required)
ignore_errors: yes
## reason for ignore_errors: yes
## "version_compare" was replaced with "version" starting ansible 2.5;
## CentOS/RHEL 7.x use ansible 2.4, so not able to grasp what version_compare is.
## Ansible 2.9 removes the version_compare and does not recognize it any longer.
## As our need is to add python2 only on versions before 2.8, if this fails
## (due to missing version_compare command), we are fine.
## We do not cover cases where it fails due to other reasons, but that is a reasonable risk,
## and that issue will be captured later in the flow.
tags: always
- name: when no python(2/3), install python3(Debian) python2(RedHat) for Ansible>=2.8
raw: test -e /usr/bin/python || (apt -y update && apt install -y python3-minimal) || (yum install -y python2 python-simplejson)
register: output
changed_when: output.stdout | length > 0
when:
- ansible_version.full is version('2.8', '>=') or ( ansible_python_interpreter is defined and ansible_python_interpreter == "/usr/bin/python3" )
# ansible_os_family conds. cannot be used as this is before gathering facts (where ansible is required)
ignore_errors: yes
tags: always
- name: gathering facts
setup:
tags: always
become: no
- name: setup repo
block:
- name: turn on the EPEL repo on CentOS/RHEL
yum:
name: epel-release
state: present
when: ansible_distribution == 'CentOS'
- name: update repositories cache for Debian
apt:
update_cache: yes
cache_valid_time: 86400
when: ansible_os_family == 'Debian'
tags:
- repo
- never