ansible-role-sensu/tasks/build_agent.yml

99 lines
1.9 KiB
YAML
Raw Normal View History

2019-02-06 21:48:49 +00:00
---
- 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
2019-02-07 21:27:01 +00:00
register: git
2019-02-06 21:48:49 +00:00
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
2019-02-07 21:27:01 +00:00
- ./cmd/sensu-agent/
2019-02-06 21:48:49 +00:00
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
2019-02-07 21:27:01 +00:00
- 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