-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathgo.yaml
88 lines (78 loc) · 2.69 KB
/
go.yaml
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
---
- name: Ensure go lang is installed and configured correctly
hosts: factory
tasks:
- name: Set PATH_SRC fact
ansible.builtin.set_fact:
PATH_SRC: "PATH={{ lookup('env', 'PATH') }}"
- name: When MacOSX ensure Go is installed
community.general.homebrew:
name:
- go
- golangci-lint
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
when: ( ansible_distribution == 'MacOSX' )
- name: When Archlinux ensure Go is installed
community.general.pacman:
name: "go"
state: latest
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
become: yes
when: ( ansible_distribution == 'Archlinux' )
- name: When Rocky 8 ensure Go is installed
block:
- name: Check if /usr/local/bin/go exists
ansible.builtin.stat:
path: /usr/local/bin/go
register: st
- name: Set GOLANG_VERSION fact
ansible.builtin.set_fact:
GOLANG_VERSION: "{{ lookup('env', 'golang_version') }}"
- name: Install Go {{ GOLANG_VERSION }}
ansible.builtin.shell: |
cd /tmp
wget https://golang.org/dl/go{{ GOLANG_VERSION }}.linux-amd64.tar.gz
tar -zxvf go{{ GOLANG_VERSION }}.linux-amd64.tar.gz -C /usr/local/bin
rm go{{ GOLANG_VERSION }}.linux-amd64.tar.gz
become: yes
when: not st.stat.exists
- name: Set PATH_SRC fact
ansible.builtin.set_fact:
PATH_SRC: "PATH=/usr/local/bin/go/bin:$PATH"
when: ( ansible_distribution == 'Rocky' )
- name: Ensure {{ HOME }}/go folders exists
ansible.builtin.file:
path: "{{ HOME }}/go/{{ item }}"
state: directory
mode: 0775
with_items:
- bin
- pkg
- src
- name: Ensure golint is installed
ansible.builtin.shell: |
{{ PATH_SRC }}
GOBIN="$HOME/go/bin"
GOPATH="$HOME/go"
PATH="$GOBIN:$PATH"
go get -u golang.org/x/lint/golint
args:
executable: /bin/bash
retries: "{{ default_retries }}"
delay: "{{ default_delay }}"
register: result
until: result is succeeded
- name: Ensure golangci-lint is installed
ansible.builtin.shell: |
{{ PATH_SRC }}
GOBIN="$HOME/go/bin"
GOPATH="$HOME/go"
PATH="$GOBIN:$PATH"
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v{{ lookup('env', 'golangci_lint_version') }}