2019-01-01 19:44:04 +00:00
|
|
|
---
|
2019-02-16 18:00:14 +00:00
|
|
|
- include_tasks: 'backend-dependencies-{{ ansible_os_family|lower }}.yml'
|
|
|
|
|
2019-01-01 19:44:04 +00:00
|
|
|
- name: install sensu-backend packages
|
2019-02-16 18:00:14 +00:00
|
|
|
package:
|
2019-01-01 19:44:04 +00:00
|
|
|
name: '{{ packages }}'
|
|
|
|
vars:
|
|
|
|
packages:
|
|
|
|
- sensu-go-backend
|
|
|
|
- sensu-go-cli
|
|
|
|
register: result
|
|
|
|
retries: 3
|
|
|
|
delay: 1
|
|
|
|
until: result is success
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: copy backend configuration file
|
|
|
|
copy:
|
|
|
|
content: '{{ sensu_backend_full_config|to_nice_yaml }}'
|
|
|
|
dest: /etc/sensu/backend.yml
|
|
|
|
owner: root
|
|
|
|
group: sensu
|
|
|
|
mode: 0640
|
|
|
|
notify: restart sensu-backend
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: enable and start sensu-backend service
|
|
|
|
systemd:
|
|
|
|
name: sensu-backend
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: wait sensu backend is started
|
|
|
|
wait_for:
|
|
|
|
port: '{{ sensu_api_url.split(":")[2]|default(80) }}'
|
|
|
|
delay: 5
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage users
|
|
|
|
sensugo_user:
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
groups: '{{ item.groups }}'
|
|
|
|
password: '{{ item.password }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_users }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage cluster roles
|
|
|
|
sensugo_cluster_role:
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
rules: '{{ item.rules }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_cluster_roles }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage namespaces
|
|
|
|
sensugo_namespace:
|
|
|
|
name: '{{ item.name }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_namespaces }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage assets
|
|
|
|
sensugo_asset:
|
|
|
|
name: '{{ item.name }}'
|
2019-02-15 19:09:49 +00:00
|
|
|
namespaces: '{{ item.namespaces|default(["default"]) }}'
|
2019-01-01 19:44:04 +00:00
|
|
|
url: '{{ item.url }}'
|
|
|
|
sha512: '{{ item.sha512 }}'
|
|
|
|
filters: '{{ item.filters|default([]) }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_assets }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage filters
|
|
|
|
sensugo_filter:
|
|
|
|
name: '{{ item.name }}'
|
2019-02-15 19:09:49 +00:00
|
|
|
namespaces: '{{ item.namespaces|default(["default"]) }}'
|
2019-01-01 19:44:04 +00:00
|
|
|
action: '{{ item.action|default("allow") }}'
|
|
|
|
expressions: '{{ item.expressions }}'
|
|
|
|
runtime_assets: '{{ item.runtime_assets|default([]) }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_filters }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage handlers
|
|
|
|
sensugo_handler:
|
|
|
|
name: '{{ item.name }}'
|
2019-02-15 19:09:49 +00:00
|
|
|
namespaces: '{{ item.namespaces|default(["default"]) }}'
|
2019-01-01 19:44:04 +00:00
|
|
|
type: '{{ item.type|default("pipe") }}'
|
|
|
|
command: '{{ item.command }}'
|
|
|
|
filters: '{{ item.filters|default([]) }}'
|
|
|
|
options: '{{ item.options|default({}) }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_handlers }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|
|
|
|
|
|
|
|
- name: manage checks
|
|
|
|
sensugo_check:
|
|
|
|
name: '{{ item.name }}'
|
2019-02-15 19:09:49 +00:00
|
|
|
namespaces: '{{ item.namespaces|default(["default"]) }}'
|
2019-01-01 19:44:04 +00:00
|
|
|
command: '{{ item.command }}'
|
|
|
|
handlers: '{{ item.handlers|default([]) }}'
|
|
|
|
subscriptions: '{{ item.subscriptions }}'
|
|
|
|
interval: '{{ item.interval|default(60) }}'
|
|
|
|
options: '{{ item.options|default({}) }}'
|
|
|
|
state: '{{ item.state|default("present") }}'
|
|
|
|
api_url: '{{ sensu_api_url }}'
|
|
|
|
api_user: '{{ sensu_api_user }}'
|
|
|
|
api_password: '{{ sensu_api_password }}'
|
|
|
|
loop: '{{ sensu_checks }}'
|
|
|
|
run_once: true
|
|
|
|
no_log: true
|
|
|
|
tags: sensu
|