ansible-role-sensu/tasks/build_agent.yml

57 lines
1.2 KiB
YAML

---
- 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