fix
This commit is contained in:
parent
130854c97e
commit
5024bfa3ea
7 changed files with 165 additions and 2 deletions
|
@ -25,3 +25,8 @@ platforms:
|
||||||
|
|
||||||
suites:
|
suites:
|
||||||
- name: default
|
- name: default
|
||||||
|
- name: build
|
||||||
|
provisioner:
|
||||||
|
extra_vars:
|
||||||
|
sensu_build: yes
|
||||||
|
sensu_build_go_version: 1.11
|
||||||
|
|
16
files/sensu-agent.service
Normal file
16
files/sensu-agent.service
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[Unit]
|
||||||
|
Description=The Sensu Agent process.
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=sensu
|
||||||
|
Group=sensu
|
||||||
|
LimitNOFILE=65535
|
||||||
|
ExecStart=/usr/local/bin/sensu-agent start
|
||||||
|
Restart=always
|
||||||
|
WorkingDirectory=/
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -12,8 +12,12 @@
|
||||||
retries: 3
|
retries: 3
|
||||||
delay: 1
|
delay: 1
|
||||||
until: result is success
|
until: result is success
|
||||||
|
when: not sensu_build
|
||||||
tags: sensu
|
tags: sensu
|
||||||
|
|
||||||
|
- import_tasks: build_agent.yml
|
||||||
|
when: sensu_build
|
||||||
|
|
||||||
- name: copy agent configuration file
|
- name: copy agent configuration file
|
||||||
copy:
|
copy:
|
||||||
content: '{{ sensu_agent_full_config|to_nice_yaml }}'
|
content: '{{ sensu_agent_full_config|to_nice_yaml }}'
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
repo: https://github.com/sensu/sensu-go/
|
repo: https://github.com/sensu/sensu-go/
|
||||||
version: '{{ sensu_build_version }}'
|
version: '{{ sensu_build_version }}'
|
||||||
dest: /usr/local/src/sensu-go
|
dest: /usr/local/src/sensu-go
|
||||||
when: git.changed or not bin.stat.exists
|
register: git
|
||||||
tags: sensu
|
tags: sensu
|
||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
- build
|
- build
|
||||||
- '-o'
|
- '-o'
|
||||||
- /usr/local/bin/sensu-agent
|
- /usr/local/bin/sensu-agent
|
||||||
- main.go
|
- ./cmd/sensu-agent/
|
||||||
environment:
|
environment:
|
||||||
GOPATH: /usr/local/src/go
|
GOPATH: /usr/local/src/go
|
||||||
GOBIN: /usr/local/src/go/bin
|
GOBIN: /usr/local/src/go/bin
|
||||||
|
@ -55,3 +55,44 @@
|
||||||
group: root
|
group: root
|
||||||
mode: 0755
|
mode: 0755
|
||||||
tags: go
|
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
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- import_tasks: repository.yml
|
- import_tasks: repository.yml
|
||||||
|
when: not sensu_build
|
||||||
|
|
||||||
- import_tasks: agent.yml
|
- import_tasks: agent.yml
|
||||||
when: sensu_agent
|
when: sensu_agent
|
||||||
|
|
18
test/integration/build/default.yml
Normal file
18
test/integration/build/default.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
- hosts: default
|
||||||
|
connection: local
|
||||||
|
vars:
|
||||||
|
sensu_agent_labels:
|
||||||
|
test: coucou
|
||||||
|
hello:
|
||||||
|
warning: 30
|
||||||
|
critical: 50
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- ansible-role-sensu
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: add repo backports
|
||||||
|
apt_repository:
|
||||||
|
repo: 'deb http://httpredir.debian.org/debian {{ansible_distribution_release}}-backports main'
|
||||||
|
state: present
|
78
test/integration/build/serverspec/default_spec.rb
Normal file
78
test/integration/build/serverspec/default_spec.rb
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
require 'serverspec'
|
||||||
|
|
||||||
|
set :backend, :exec
|
||||||
|
|
||||||
|
puts
|
||||||
|
puts '================================'
|
||||||
|
puts %x(ansible --version)
|
||||||
|
puts '================================'
|
||||||
|
|
||||||
|
%w[
|
||||||
|
sensu-go-agent
|
||||||
|
sensu-go-cli
|
||||||
|
sensu-go-backend
|
||||||
|
monitoring-plugins-basic
|
||||||
|
].each do |package|
|
||||||
|
describe package(package) do
|
||||||
|
it { should be_installed }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
%w[
|
||||||
|
sensu-agent
|
||||||
|
sensu-backend
|
||||||
|
].each do |service|
|
||||||
|
describe service(service) do
|
||||||
|
it { should be_enabled }
|
||||||
|
it { should be_running }
|
||||||
|
it { should be_running.under('systemd') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
[3000, 8080, 8081].each do |port|
|
||||||
|
describe port(port) do
|
||||||
|
it { should be_listening.with('tcp6') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command(
|
||||||
|
'sensuctl configure -n --password "P@ssw0rd!" ' \
|
||||||
|
'--url http://127.0.0.1:8080 --username admin --format tabular'
|
||||||
|
) do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl namespace list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match 'supernamespace' }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl user list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match(/johndoe.*\s+devops,users\s+.*true/) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl asset list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match(/superasset.*\s+.*test.sh\s+cf83e13/) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl handler list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match(/mail.*\s+pipe\s+.*echo test \| mail -s coucou\s+/) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl filter list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match(/state_changed.*\s+allow\s+event\.check\.occurrences == 1/) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl cluster-role list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match(/view.*\s+1/) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe command('sensuctl check list') do
|
||||||
|
its(:exit_status) { should eq 0 }
|
||||||
|
its(:stdout) { should match(/ping.*\s+ping -c 1 127.0.0.1\s+60\s+.*\s+linux\s+/) }
|
||||||
|
end
|
Loading…
Reference in a new issue