Skip to content
Snippets Groups Projects
Commit 5a7c9c40 authored by jurgenhaas's avatar jurgenhaas
Browse files

Initial code for the role

parent f4417dbd
No related branches found
No related tags found
No related merge requests found
ansible-role-serverdensity
==========================
Ansible role to install and configure Server Density Agent
==========================================================
This is currently developed and tested for Ubuntu only but should easily be extended to other Nix's later on.
See defaults/main.yml for variables that you should re-define in your own inventory.
---
# file: roles/serverdensity/defaults/main.yml
sd_url: false
sd_api_token: ''
sd_api_cache_file: '/tmp/sd_cache'
sd_agent_key: ''
sd_logging_level: 'info'
sd_plugins: []
sd_groups:
apache: 'all'
mysql: 'all'
proxy: 'all'
---
# file: roles/serverdensity/handlers/main.yml
- name: 'ServerDensity | Restart Agent'
service: name=sd-agent state=restarted
---
galaxy_info:
author: "jurgenhaas"
company: "PARAGON Executive Services GmbH"
min_ansible_version: 1.5
platforms:
- name: Ubuntu
versions:
- precise
- quantal
- raring
- saucy
- trusty
categories:
- monitoring
---
# file: roles/serverdensity/tasks/main.yml
- name: 'ServerDensity | Init SD plugin'
local_action:
serverdensity
api_token={{sd_api_token}}
cleanup=true
cache='{{sd_api_cache_file}}'
- name: 'ServerDensity | Install Public Repo Key'
apt_key:
url='https://www.serverdensity.com/downloads/boxedice-public.key'
state=present
- name: 'ServerDensity | Add ServerDensity Repository To Apt'
copy:
content='deb http://www.serverdensity.com/downloads/linux/deb all main'
dest='/etc/apt/sources.list.d/sd-agent.list'
- name: 'ServerDensity | Install The Agent'
apt:
pkg=sd-agent
state=installed
update_cache=yes
notify: 'ServerDensity | Restart Agent'
- name: 'ServerDensity | Create Plugins Directory'
file:
dest='/usr/bin/sd-agent/plugins'
state=directory
mode=755
- name: 'ServerDensity | Copy Plugins'
copy:
src={{inventory_dir}}/files/sd-plugins/{{item.1}}
dest=/usr/bin/sd-agent/plugins/{{item.1}}
with_items: sd_plugins|dictsort
notify: 'ServerDensity | Restart Agent'
- name: 'ServerDensity | Configure The Agent'
template: src=config.cfg
dest=/etc/sd-agent/config.cfg
owner=root
group=root
mode=0644
when: sd_agent_key != ''
notify: 'ServerDensity | Restart Agent'
# Server Density Agent Config
# Docs: https://support.serverdensity.com/hc/en-us/articles/201003178-Agent-config-variables
# Plugins: http://plugins.serverdensity.com/
[Main]
sd_url: {{sd_url}}
agent_key: {{sd_agent_key}}
plugin_directory: /usr/bin/sd-agent/plugins
logging_level: {{sd_logging_level}}
{% if inventory_hostname in groups[sd_groups.apache] %}
# Apache
# See https://support.serverdensity.com/hc/en-us/articles/201253343-Apache-monitoring-Linux-Mac-and-FreeBSD
apache_status_url: http://{{inventory_hostname}}/server-status/?auto
apache_status_user:
apache_status_pass:
{% endif %}
{% if inventory_hostname in groups[sd_groups.mysql] %}
# MySQL
# See https://support.serverdensity.com/hc/en-us/articles/201013827-MySQL-monitoring-Linux-Mac-and-FreeBSD
mysql_server: 127.0.0.1
mysql_user: root
mysql_pass: root
{% endif %}
{% if inventory_hostname in groups[sd_groups.proxy] %}
haproxy_svname: {{inventory_hostname}}
haproxy_url: http://127.0.0.1:7000/haproxy_stats
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment