Skip to content
Snippets Groups Projects
Commit 365f3fd1 authored by jurgenhaas's avatar jurgenhaas
Browse files

Issue #2 Update agent to version 2

parent 7dd73d1d
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
# file: roles/serverdensity/defaults/main.yml
sd_update_remote: yes
sd_account: ''
sd_url: ''
sd_api_token: ''
sd_api_cache_file: no
......@@ -15,7 +16,6 @@ sd_groups:
mysql: 'none'
proxy: 'none'
sd_repo_public_key_uri: 'https://www.serverdensity.com/downloads/boxedice-public.key'
sd_agent_plugins_dir: '/usr/bin/sd-agent/plugins'
sd_repo_public_key_uri: 'https://archive.serverdensity.com/sd-packaging-public.key'
sd_agent_plugins_dir: '/usr/share/python/sd-agent/checks.d/plugins'
sd_plugins_files_dir: "{{ playbook_dir }}/files/sd-plugins"
sd_template_config: 'config.cfg'
---
# file: roles/serverdensity/tasks/apache.yml
- name: "ServerDensity | Apache | Install The Agent"
apt:
pkg=sd-agent-apache
state=installed
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | Apache | Configure The Agent"
template:
src=apache.yaml
dest=/etc/sd-agent/conf.d/apache.yaml
owner=root
group=root
mode=0644
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | Apache | Enable some required modules"
apache2_module:
name={{ item }}
......
---
# file: roles/serverdensity/tasks/main.yml
- name: "ServerDensity | Check for old version 1"
shell: ls /etc/sd-agent/conf.d/disk.yaml.default
register: sd_v2_available
ignore_errors: yes
changed_when: False
- include: uninstallv1.yml
when: sd_v2_available.stdout != '/etc/sd-agent/conf.d/disk.yaml.default'
- name: "ServerDensity | Init SD plugin"
local_action:
serverdensity
......@@ -17,7 +26,7 @@
- name: "ServerDensity | Add ServerDensity Repository To Apt"
copy:
content='deb http://www.serverdensity.com/downloads/linux/deb all main'
content='deb http://archive.serverdensity.com/ubuntu/ all main'
dest=/etc/apt/sources.list.d/sd-agent.list
mode=644
......@@ -44,13 +53,20 @@
- name: "ServerDensity | Configure The Agent"
template:
src={{ sd_template_config }}
dest=/etc/sd-agent/config.cfg
src={{ item }}
dest=/etc/sd-agent/{{ item }}
owner=root
group=root
mode=0644
with_items:
- 'config.cfg'
- 'plugins.cfg'
#- 'supervisor.conf'
when: sd_agent_key != ''
notify: "ServerDensity | Restart Agent"
- include: apache.yml
when: sd_groups.apache != 'none' and inventory_hostname in groups[sd_groups.apache]
- include: mysql.yml
when: sd_groups.mysql != 'none' and inventory_hostname in groups[sd_groups.mysql]
---
# file: roles/serverdensity/tasks/mysql.yml
- name: "ServerDensity | MySQL | Install The Agent"
apt:
pkg=sd-agent-mysql
state=installed
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | MySQL | Configure The Agent"
template:
src=mysql.yaml
dest=/etc/sd-agent/conf.d/mysql.yaml
owner=root
group=root
mode=0644
notify: "ServerDensity | Restart Agent"
---
# file: roles/serverdensity/tasks/uninstallv1.yml
# Stop agent
- name: "ServerDensity | Stop v1 Agent"
service:
name=sd-agent
state=stopped
# Uninstall agent
- name: "ServerDensity | Uninstall v1 Agent"
apt:
pkg=sd-agent
state=absent
# Remove /usr/bin/sd-agent
- name: "ServerDensity | Create Plugins Directory"
file:
dest=/usr/bin/sd-agent
state=absent
init_config:
instances:
- apache_status_url: http://{{ inventory_hostname }}/server-status?auto
# Server Density Agent Config
# Docs: https://support.serverdensity.com/hc/en-us/articles/201003178-Agent-config-variables
# Plugins: http://plugins.serverdensity.com/
# Version 2
[Main]
sd_url: {{ sd_url }}
sd_account: {{ sd_account }}
agent_key: {{ sd_agent_key }}
plugin_directory: {{ sd_agent_plugins_dir }}
logging_level: {{ sd_logging_level }}
plugin_directory: {{ sd_agent_plugins_dir }}
{% if sd_groups.apache != 'none' and inventory_hostname in groups[sd_groups.apache] %}
# Apache
# See https://support.serverdensity.com/hc/en-us/articles/201253343-Apache-monitoring-Linux-Mac-and-FreeBSD
# ========================================================================== #
# Logging
# See https://support.serverdensity.com/hc/en-us/articles/213093038-Log-levels-agent-debug-mode
# ========================================================================== #
apache_status_url: http://{{ inventory_hostname }}/server-status/?auto
apache_status_user:
apache_status_pass:
{% endif %}
log_level: {{ sd_logging_level }}
{% if sd_groups.mysql != 'none' and inventory_hostname in groups[sd_groups.mysql] %}
# MySQL
# See https://support.serverdensity.com/hc/en-us/articles/201013827-MySQL-monitoring-Linux-Mac-and-FreeBSD
# collector_log_file: /var/log/sd-agent/collector.log
# forwarder_log_file: /var/log/sd-agent/forwarder.log
mysql_server: 127.0.0.1
mysql_user: root
mysql_pass: root
{% endif %}
{% if sd_groups.proxy != 'none' and inventory_hostname in groups[sd_groups.proxy] %}
haproxy_svname: {{ inventory_hostname }}
haproxy_url: http://127.0.0.1:7000/haproxy_stats
{% endif %}
# if syslog is enabled but a host and port are not set, a local domain socket
# connection will be attempted
#
# log_to_syslog: yes
# syslog_host:
# syslog_port:
init_config:
instances:
- server: 127.0.0.1
user: root
pass: root
# PLugins config
{% if sd_groups.proxy != 'none' and inventory_hostname in groups[sd_groups.proxy] %}
[haproxy]
haproxy_svname: {{ inventory_hostname }}
haproxy_url: http://127.0.0.1:7000/haproxy_stats
{% endif %}
[supervisorctl]
serverurl = unix:///var/tmp/sd-supervisor.sock
[unix_http_server]
file=/var/tmp/sd-supervisor.sock
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisord]
http_port = /var/tmp/sd-supervisor.sock
minfds = 1024
minprocs = 200
loglevel = info
logfile = /var/log/sd-agent/supervisord.log
logfile_maxbytes = 50MB
nodaemon = false
pidfile = /var/run/sd-supervisord.pid
logfile_backups = 10
environment=PYTHONPATH=/usr/share/python/sd-agent,LANG=POSIX
[program:collector]
command=/usr/share/python/sd-agent/bin/python /usr/share/python/sd-agent/agent.py foreground --use-local-forwarder
stdout_logfile=NONE
stderr_logfile=NONE
priority=999
startsecs=5
startretries=3
user=sd-agent
environment=PYTHONPATH='/usr/share/python/sd-agent:$PYTHONPATH'
[program:forwarder]
command=/usr/share/python/sd-agent/bin/python /usr/share/python/sd-agent/sdagent.py
stdout_logfile=NONE
stderr_logfile=NONE
startsecs=5
startretries=3
priority=998
user=sd-agent
[group:sd-agent]
programs=forwarder,collector
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