-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
main.yml
126 lines (114 loc) · 4.37 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
##############
# GIT_Source #
##############
# Conditions:
# Check if git is installed. If so git_installed.rc will equal 0, then test if git is at the correct version level.
# If git_installed.rc does NOT equal 0 (not installed) or if git_installed.rc equals 0 (installed) and its at a lower version than 2.15 then...
# Process with downloing and installing git
- name: Test if git is installed on path
shell: git --version >/dev/null
failed_when: false
register: git_installed
changed_when: false
tags:
- git_source
# Emits 'git used in place of git module'
- skip_ansible_lint
- name: Test if git is installed at the correct version
shell: git --version | sed -e 's/git version //g' | awk -F'[.]' '{print $1 "." $2}'
when: git_installed.rc == 0
register: git_version
changed_when: false
tags:
- git_source
# Emits 'git used in place of git module'
- skip_ansible_lint
- name: Download git source
get_url:
url: https://www.kernel.org/pub/software/scm/git/git-2.15.0.tar.xz
dest: /tmp/git-2.15.0.tar.xz
mode: 0440
checksum: sha256:107116489f10b758b51af1c5dbdb9a274917b0fb67dc8eaefcdabc7bc3eb3e6a
retries: 3
delay: 5
register: git_download
until: git_download is not failed
when:
- (git_installed.rc != 0 ) or (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_distribution != "FreeBSD"
tags: git_source
- name: Extract git source
unarchive:
src: /tmp/git-2.15.0.tar.xz
dest: /tmp/
extra_opts:
- --no-same-owner
copy: False
when:
- (git_installed.rc != 0 ) or (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_distribution != "FreeBSD"
tags: git_source
- name: Find Curl directory
shell: ls -ld /usr/local/curl-* | awk '{print $9}'
register: curl_install_dir
changed_when: false
when:
- (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6")
tags: git_source
- name: Compile and install git from source on RHEL/CentOS6
shell: cd /tmp/git-2.15.0 && ./configure --with-curl={{ curl_install_dir.stdout }} --prefix=/usr/local --without-tcltk && make clean && make -j {{ ansible_processor_vcpus }} && make install
become: yes
when:
- (git_installed.rc != 0 ) or (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_architecture != "s390x"
- (( ansible_distribution == "RedHat" or ansible_distribution == "CentOS") and ansible_distribution_major_version == "6")
tags: git_source
- name: Compile and install git from source on everything else
shell: cd /tmp/git-2.15.0 && ./configure --prefix=/usr/local --without-tcltk && make clean && make -j {{ ansible_processor_vcpus }} && make install
become: yes
when:
- (git_installed.rc != 0 ) or (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_architecture != "s390x"
- ansible_distribution != "FreeBSD"
- not(( ansible_distribution == "RedHat" or ansible_distribution == "CentOS") and ansible_distribution_major_version == "6")
tags: git_source
- name: Compile and install git from source on s390x
shell: cd /tmp/git-2.15.0 && ./configure --prefix=/usr/local --without-tcltk && make -j {{ ansible_processor_cores }} && make install
become: yes
when:
- (git_installed.rc != 0 ) or (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_architecture == "s390x"
- ansible_distribution != "FreeBSD"
tags: git_source
- name: Remove system git if needed (yum)
yum:
name:
- git
- perl-Git
state: absent
when:
- (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_distribution == "CentOS" or ansible_distribution == "RedHat"
tags:
- git_source
- dont_remove_system
- name: Remove system git if needed (zypper)
zypper:
name: git
state: absent
when:
- (git_installed.rc == 0 and git_version.stdout is version_compare('2.15', operator='lt'))
- ansible_distribution == "SLES" or ansible_distribution == "openSUSE"
tags:
- git_source
- dont_remove_system
- name: Remove downloaded packages for git source
file:
path: "{{ item }}"
state: absent
with_items:
- /tmp/git-2.15.0
- /tmp/git-2.15.0.tar.xz
failed_when: false
tags: git_source