ansible-role-sensu/tasks/build_agent.yml
2019-02-08 18:44:47 +01:00

98 lines
1.9 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
register: git
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
- ./cmd/sensu-agent/
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
- name: create configuration folder
file:
path: /etc/sensu
owner: root
group: root
mode: 0755
state: directory
tags: go
- name: create sensu group
group:
name: sensu
gid: 998
tags: go
- name: create sensu user
user:
name: sensu
group: sensu
uid: 996
home: /opt/sensu
shell: /bin/false
comment: Sensu Monitoring Framework
tags: go
- name: copy systemd service
copy:
src: sensu-agent.service
dest: /etc/systemd/system/sensu-agent.service
owner: root
group: root
mode: 0644
register: systemd
tags: go
- name: reload systemd
systemd:
daemon_reload: yes
when: systemd.changed
tags: go