-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgo_build.yml
85 lines (72 loc) · 2.32 KB
/
go_build.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
- hosts: localhost
vars:
build_packages:
- 'gcc-c++'
- 'libvirt-devel'
work_dir: '/tmp'
GOBIN: "{{ work_dir }}/go/bin"
GOPATH: "{{ work_dir }}/go"
git_repo_branch: 'release-4.1'
environment:
GOBIN: "{{ GOBIN }}"
GOPATH: "{{ GOPATH }}"
PATH: "{{ GOBIN }}:{{ ansible_env.PATH }}"
pre_tasks:
- block:
- name: Check if GOLANG installed
command: go version
register: go_ver
ignore_errors: yes
- name: Check the Go Lang verion
fail:
msg="GO Lang Verion {{go_ver.stdout|regex_search('(\d).(\d*).(\d*)')}} but it should be higher than 1.10.3"
when: go_ver is succeeded and go_ver.stdout|regex_search('(\d).(\d*).(\d*)')|int is version('1.10.3', '>=')
tasks:
- block:
- name: Create go directory
file:
state: directory
path: "{{ work_dir }}/go/{{ item }}"
with_items:
- src
- pkg
- bin
- name: Add GO environment to ~/.bashrc
lineinfile:
path: "~/.bashrc"
line: "{{ item }}"
with_items:
- "export GOBIN={{ work_dir }}/go/bin"
- "export GOPATH={{ work_dir }}/go"
- "export PATH=${GOBIN}:${PATH}"
- block:
- name: Install build packages
package:
name: "{{ build_packages }}"
become: yes
- name: GoLang install
package:
name: "golang-bin"
when: go_ver is failed
become: yes
- name: Download Dep Install file
get_url:
url: https://raw.githubusercontent.com/golang/dep/master/install.sh
dest: "{{ work_dir }}/install.sh"
mode: 0777
- name: Install Dep
shell: "{{ work_dir }}/install.sh"
- block:
- name: Download Installer Repository
git:
repo: https://github.com/openshift/installer.git
dest: "{{ work_dir }}/go/src/github.com/openshift/installer"
version: "{{ git_repo_branch }}"
- name: Download dependencies
shell: "dep ensure"
args:
chdir: "{{ work_dir }}/go/src/github.com/openshift/installer"
- name: Build
shell: "TAGS=libvirt hack/build.sh"
args:
chdir: "{{ work_dir }}/go/src/github.com/openshift/installer"