Skip to content

Commit 2f1dc25

Browse files
committed
validate git version to be 2+
1 parent 3e66e8c commit 2f1dc25

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

tasks/main.yml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
22

33
- name: install centos software collections
4-
package:
4+
yum:
55
name: centos-release-scl-rh
66
state: present
7+
update_cache: true
78
register: network_access
89
until: network_access is success
9-
retries: 10
10+
retries: 3
1011
delay: 2
1112
when:
1213
- collections_enabled|bool
@@ -30,32 +31,34 @@
3031
- name: Set git
3132
set_fact:
3233
base_git: git
33-
when:
34-
- ansible_os_family == 'RedHat'
35-
- ansible_distribution_major_version|int > 7
3634
tags:
3735
- git
3836
- base_git
37+
- test
3938

4039
- name: Set git
4140
set_fact:
4241
base_git: rh-git218
4342
when:
4443
- ansible_os_family == 'RedHat'
4544
- ansible_distribution_major_version|int == 7
45+
- collections_enabled|bool
4646
tags:
4747
- git
4848
- base_git
49+
- test
4950

5051
- name: Set git
5152
set_fact:
5253
base_git: rh-git29
5354
when:
5455
- ansible_os_family == 'RedHat'
5556
- ansible_distribution_major_version|int == 6
57+
- collections_enabled|bool
5658
tags:
5759
- git
5860
- base_git
61+
- test
5962

6063
- name: Set git packages
6164
when: collections_enabled|bool and ansible_os_family == 'RedHat'
@@ -94,6 +97,8 @@
9497
stat:
9598
path: "/opt/rh/{{ base_git }}/enable"
9699
register: rh_git_env
100+
tags:
101+
- test
97102

98103
- name: Enable Git software collection
99104
file:
@@ -107,25 +112,17 @@
107112
tags:
108113
- git
109114
- base_git
110-
- notest
115+
- test
111116

112117
- name: Disable Git software collection
113118
file:
114119
path: /etc/profile.d/rh-git.sh
115120
state: absent
116-
when: not collections_enabled|bool and ansible_os_family == 'RedHat'
121+
when: collections_enabled|bool and ansible_os_family == 'RedHat'
117122
tags:
118123
- git
119124
- notest
120125

121-
- name: Disable Git software collection
122-
file:
123-
path: /etc/profile.d/rh-git.sh
124-
state: absent
125-
when: not collections_enabled|bool and ansible_os_family == 'RedHat'
126-
tags:
127-
- git
128-
129126
- name: Install Git
130127
become: true
131128
package:
@@ -140,6 +137,19 @@
140137
- git
141138
- base_git
142139

140+
- name: Collect git version
141+
command: bash --login -c 'git --version'
142+
register: git_version
143+
changed_when: false
144+
tags:
145+
- test
146+
147+
- name: Display git version
148+
debug:
149+
msg: "{{ base_git }} {{ git_version.stdout }}"
150+
tags:
151+
- test
152+
143153
- name: Disable Git software collection
144154
file:
145155
path: /etc/profile.d/rh-git.sh

0 commit comments

Comments
 (0)