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

ansible-playbooks/general#85 Linting

parent f02df753
No related branches found
No related tags found
No related merge requests found
......@@ -55,8 +55,8 @@ Example:
```
sd_plugins:
updatestatus: 'UpdateStatus.py'
redis: 'Redis.py'
updatestatus: UpdateStatus.py
redis: Redis.py
```
This variable is expected to be defined as a set so that hash_behaviour=merge can be used so that you can define this variable in several of your groups and that this role is going to install the superset of all the group a specific host belings to.
......@@ -68,9 +68,9 @@ The key of each entry should be unique across your inventory and the value is a
Default:
```
apache: 'none'
mysql: 'none'
proxy: 'none'
apache: none
mysql: none
proxy: none
```
Certain sections in the agent configuration are only relevant for certain hosts and by providing valid inventory group names for those sections (currently apache, mysql, proxy) you can make sure that for all hosts in those groups the relevant parts in the agent configuration get written to that host.
......
......@@ -2,23 +2,23 @@
# file: roles/serverdensity/defaults/main.yml
sd_update_remote: yes
sd_account: ''
sd_url: ''
sd_api_token: ''
sd_account:
sd_url:
sd_api_token:
sd_api_cache_file: no
sd_agent_key: ''
sd_logging_level: 'info'
sd_agent_key:
sd_logging_level: info
sd_alert_cleanup: no
sd_force_update: yes
sd_groups:
apache: 'none'
mysql: 'none'
proxy: 'none'
apache: none
mysql: none
proxy: none
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_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_uninstallv1: no
mysql_root_password: 'root'
mysql_root_password: root
---
# file: roles/serverdensity/handlers/main.yml
- name: "ServerDensity | Restart Agent"
- name: ServerDensity | Restart Agent
service:
name=sd-agent
state=restarted
- name: "ServerDensity | Restart Apache"
- name: ServerDensity | Restart Apache
service:
name=apache2
state=restarted
---
# file: roles/serverdensity/tasks/apache.yml
- name: "ServerDensity | Apache | Install The Agent"
- name: ServerDensity | Apache | Install The Agent
apt:
pkg=sd-agent-apache
state=present
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | Apache | Configure The Agent"
- name: ServerDensity | Apache | Configure The Agent
template:
src=apache.yaml
dest=/etc/sd-agent/conf.d/apache.yaml
......@@ -16,7 +16,7 @@
mode='644'
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | Apache | Enable some required modules"
- name: ServerDensity | Apache | Enable some required modules
apache2_module:
name={{ item }}
state=present
......@@ -24,7 +24,7 @@
- status
notify: "ServerDensity | Restart Apache"
- name: "ServerDensity | Apache | Configuration file for ServerDensity"
- name: ServerDensity | Apache | Configuration file for ServerDensity
template:
src=etc-apache2-sites-available-sd-agent
dest=/etc/apache2/sites-available/sd-agent{{ apache_conf_ext|default('.conf') }}
......@@ -33,6 +33,6 @@
mode='644'
notify: "ServerDensity | Restart Apache"
- name: "ServerDensity | Apache | Enable the sd-agent site"
- name: ServerDensity | Apache | Enable the sd-agent site
command: a2ensite sd-agent creates=/etc/apache2/sites-enabled/sd-agent{{ apache_conf_ext|default('.conf') }}
notify: "ServerDensity | Restart Apache"
---
# file: roles/serverdensity/tasks/main.yml
- name: "ServerDensity Role"
set_fact: role_serverdensity_started=true
tags: 'always'
- name: ServerDensity Role
set_fact:
role_serverdensity_started: yes
tags:
- always
- block:
- import_tasks: serverdensity.yml
when: sd_api_token != ''
when: '"serverdensity" not in excluded_roles'
when: not excluded_roles or "serverdensity" not in excluded_roles
---
# file: roles/serverdensity/tasks/mysql.yml
- name: "ServerDensity | MySQL | Install The Agent"
- name: ServerDensity | MySQL | Install The Agent
apt:
pkg=sd-agent-mysql
state=present
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | MySQL | Configure The Agent"
- name: ServerDensity | MySQL | Configure The Agent
template:
src=mysql.yaml
dest=/etc/sd-agent/conf.d/mysql.yaml
......
......@@ -4,7 +4,7 @@
- import_tasks: uninstallv1.yml
when: sd_uninstallv1
- name: "ServerDensity | Init SD plugin"
- name: ServerDensity | Init SD plugin
local_action:
serverdensity
api_token={{ sd_api_token }}
......@@ -13,38 +13,38 @@
cache={{ sd_api_cache_file }}
when: sd_update_remote
- name: "ServerDensity | Install Public Repo Key"
- name: ServerDensity | Install Public Repo Key
apt_key:
url={{ sd_repo_public_key_uri }}
state=present
- name: "ServerDensity | Add ServerDensity Repository To Apt"
- name: ServerDensity | Add ServerDensity Repository To Apt
copy:
content='deb http://archive.serverdensity.com/ubuntu/ all main'
dest=/etc/apt/sources.list.d/sd-agent.list
mode='644'
- name: "ServerDensity | Install The Agent"
- name: ServerDensity | Install The Agent
apt:
pkg=sd-agent
state=present
update_cache=yes
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | Create Plugins Directory"
- name: ServerDensity | Create Plugins Directory
file:
dest={{ sd_agent_plugins_dir }}
state=directory
mode='755'
- name: "ServerDensity | Copy Plugins"
- name: ServerDensity | Copy Plugins
copy:
src={{ sd_plugins_files_dir }}/{{ item }}
dest={{ sd_agent_plugins_dir }}/{{ item }}
with_items: '{{ sd_plugins|default([]) }}'
notify: "ServerDensity | Restart Agent"
- name: "ServerDensity | Configure The Agent"
- name: ServerDensity | Configure The Agent
template:
src={{ item }}
dest=/etc/sd-agent/{{ item }}
......@@ -52,9 +52,9 @@
group=root
mode='644'
with_items:
- 'config.cfg'
- 'plugins.cfg'
#- 'supervisor.conf'
- config.cfg
- plugins.cfg
#- supervisor.conf
when: sd_agent_key != ''
notify: "ServerDensity | Restart Agent"
......
......@@ -2,19 +2,19 @@
# file: roles/serverdensity/tasks/uninstallv1.yml
# Stop agent
- name: "ServerDensity | Stop v1 Agent"
- name: ServerDensity | Stop v1 Agent
service:
name=sd-agent
state=stopped
# Uninstall agent
- name: "ServerDensity | Uninstall v1 Agent"
- name: ServerDensity | Uninstall v1 Agent
apt:
pkg=sd-agent
state=absent
# Remove /usr/bin/sd-agent
- name: "ServerDensity | Remove Plugins Directory"
- name: ServerDensity | Remove Plugins Directory
file:
dest=/usr/bin/sd-agent
state=absent
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