feat: add tasks to build sensu-agent
This commit is contained in:
parent
252f7ea6d7
commit
130854c97e
2 changed files with 61 additions and 0 deletions
|
@ -2,6 +2,10 @@
|
|||
sensu_agent: yes
|
||||
sensu_backend: no
|
||||
|
||||
sensu_build_agent: no
|
||||
sensu_build_go_version: 1.7
|
||||
sensu_build_version: 5.1.1
|
||||
|
||||
sensu_repository_system: '{{ ansible_distribution|lower }}'
|
||||
sensu_repository_release: '{{ ansible_distribution_release }}'
|
||||
|
||||
|
|
57
tasks/build_agent.yml
Normal file
57
tasks/build_agent.yml
Normal file
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
- name: install build dependencies
|
||||
apt:
|
||||
name: 'golang-{{ sensu_build_go_version }}'
|
||||
tags: sensu
|
||||
|
||||
- name: check if binary exist
|
||||
stat:
|
||||
path: /usr/local/bin/sensu-agent
|
||||
register: bin
|
||||
tags: sensu
|
||||
|
||||
- name: download source code
|
||||
git:
|
||||
repo: https://github.com/sensu/sensu-go/
|
||||
version: '{{ sensu_build_version }}'
|
||||
dest: /usr/local/src/sensu-go
|
||||
when: git.changed or not bin.stat.exists
|
||||
tags: sensu
|
||||
|
||||
- name: install dependencies
|
||||
command:
|
||||
args:
|
||||
chdir: /usr/local/src/sensu-go
|
||||
argv:
|
||||
- '/usr/lib/go-{{ sensu_build_go_version }}/bin/go'
|
||||
- get
|
||||
- ./cmd/sensu-agent/
|
||||
environment:
|
||||
GOPATH: /usr/local/src/go
|
||||
GOBIN: /usr/local/src/go/bin
|
||||
when: git.changed or not bin.stat.exists
|
||||
tags: sensu
|
||||
|
||||
- name: build program
|
||||
command:
|
||||
args:
|
||||
chdir: /usr/local/src/sensu-go
|
||||
argv:
|
||||
- '/usr/lib/go-{{ sensu_build_go_version }}/bin/go'
|
||||
- build
|
||||
- '-o'
|
||||
- /usr/local/bin/sensu-agent
|
||||
- main.go
|
||||
environment:
|
||||
GOPATH: /usr/local/src/go
|
||||
GOBIN: /usr/local/src/go/bin
|
||||
when: git.changed or not bin.stat.exists
|
||||
tags: go
|
||||
|
||||
- name: set permission on binary
|
||||
file:
|
||||
path: /usr/local/bin/sensu-agent
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
tags: go
|
Loading…
Reference in a new issue