Add basic Sensu installation and configuration with Ansible.

This commit is contained in:
Scott Wallace 2018-03-06 18:11:42 +00:00
parent f49c4af5fd
commit 86a9e457d1
10 changed files with 253 additions and 4 deletions

View file

@ -1,4 +1,8 @@
mac_desktops: mac_desktops:
hosts: hosts:
localhost: localhost:
ansible_connection: local ansible_connection: local
home_servers:
hosts:
homer

View file

@ -0,0 +1,3 @@
- name: restart firewalld
service: name=firewalld state=restarted
become: true

View file

@ -0,0 +1,3 @@
- name: Home server handlers
import_tasks: sensu.yaml
- import_tasks: firewalld.yaml

View file

@ -0,0 +1,7 @@
- name: restart sensu-client
service: name=sensu-client state=restarted
become: true
- name: restart uchiwa
service: name=uchiwa state=restarted
become: true

View file

@ -0,0 +1,16 @@
- name: Basic package installs
tags:
- install
yum:
name: "{{ item }}"
state: latest
with_items:
- epel-release
- git
- lsof
- net-tools
- psmisc
- rsync
- telnet
- vim
become: true

View file

@ -0,0 +1,3 @@
- name: Home server tasks
import_tasks: basics.yaml
- import_tasks: sensu.yaml

View file

@ -0,0 +1,156 @@
- name: Add Sensu repo
tags:
- install
yum_repository:
name: sensu
description: Sensu YUM repo
baseurl: https://sensu.global.ssl.fastly.net/yum/$releasever/$basearch/
gpgcheck: false
become: true
- name: Install Erlang
tags:
- install
yum:
name: erlang
state: present
become: true
- name: Install RabbitMQ & Redis
tags:
- install
yum:
name: "{{ item }}"
state: present
become: true
with_items:
- http://www.rabbitmq.com/releases/rabbitmq-server/current/rabbitmq-server-3.6.15-1.el7.noarch.rpm
- redis
- name: Install the latest version of Sensu
tags:
- install
yum:
name: "{{ item }}"
state: latest
become: true
with_items:
- sensu
- uchiwa
- name: Set Sensu base path
tags:
- config
set_fact:
sensu_basepath: /etc/sensu
- name: Configure Sensu client
tags:
- config
sensu_client:
subscriptions:
- default
notify:
- restart sensu-client
become: true
- name: Configure the Sensu transport
tags:
- config
copy:
content: |
{
"transport": {
"name": "rabbitmq",
"reconnect_on_error": true
}
}
dest: "{{ sensu_basepath }}/conf.d/transport.json"
become: true
- name: Configure the Sensu API
tags:
- config
copy:
content: |
{
"api": {
"host": "localhost",
"bind": "0.0.0.0",
"port": 4567
}
}
dest: "{{ sensu_basepath }}/conf.d/api.json"
become: true
- name: Configure Redis
tags:
- config
copy:
content: |
{
"redis": {
"host": "127.0.0.1",
"port": 6379
}
}
dest: "{{ sensu_basepath }}/conf.d/redis.json"
notify:
- restart sensu-client
become: true
- name: Configure Uchiwa dashboard
tags:
- config
copy:
content: |
{
"sensu": [
{
"name": "home network",
"host": "localhost",
"port": 4567,
"timeout": 10
}
],
"uchiwa": {
"host": "0.0.0.0",
"port": 3000,
"refresh": 10
}
}
dest: "{{ sensu_basepath }}/uchiwa.json"
notify:
- restart uchiwa
become: true
- name: Enable Sensu services
tags:
- services
service:
name: "{{ item }}"
enabled: true
state: started
with_items:
- sensu-client
- sensu-server
- sensu-api
- uchiwa
- rabbitmq-server
- redis
become: true
- name: Uchiwa firewalld
tags:
- services
firewalld:
port: 3000/tcp
permanent: true
zone: public
state: enabled
notify:
- restart firewalld
become: true
- import_tasks: sensu_checks.yaml

View file

@ -0,0 +1,51 @@
- name: Install Sensu basic checks
tags:
- install
command: "sensu-install -p {{ item }}"
become: true
with_items:
- cpu-checks
- disk-checks
- memory-checks
- process-checks
- load-checks
- vmstats
- name: Get CPU metrics
tags:
- config
sensu_check:
name: CPU
command: /opt/sensu/embedded/bin/check-cpu.rb -w 80 -c 90
metric: yes
handlers: default
subscribers: default
interval: 60
notify: restart sensu-server
become: true
- name: Get disk metrics
tags:
- config
sensu_check:
name: Disk
command: /opt/sensu/embedded/bin/check-disk-usage.rb -t xfs -w 80 -c 90
metric: yes
handlers: default
subscribers: default
interval: 60
notify: restart sensu-server
become: true
- name: Get memory metrics
tags:
- config
sensu_check:
name: Memory
command: /opt/sensu/embedded/bin/check-memory-percent.rb -w 80 -c 90
metric: yes
handlers: default
subscribers: default
interval: 60
notify: restart sensu-server
become: true

View file

@ -38,6 +38,7 @@ homebrew_cask_items:
- handbrake - handbrake
- iterm2 - iterm2
- itsycal - itsycal
- keybase
- osxfuse - osxfuse
- resilio-sync - resilio-sync
- signal - signal

View file

@ -1,4 +1,9 @@
- name: Mac desktops - name: Mac desktops
hosts: mac_desktops hosts: mac_desktops
roles: roles:
- mac_desktop - mac_desktop
- name: Home server
hosts: home_servers
roles:
- home_server