From e7fd0d2241903c3a1f11cc5761e89d49f2e4fc21 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Mon, 10 Jun 2019 12:50:25 +0200
Subject: [PATCH] ansible-playbooks/general#85 Linting

---
 README.md               | 10 +++++-----
 defaults/main.yml       | 22 +++++++++++-----------
 handlers/main.yml       |  4 ++--
 tasks/apache.yml        | 10 +++++-----
 tasks/main.yml          | 10 ++++++----
 tasks/mysql.yml         |  4 ++--
 tasks/serverdensity.yml | 20 ++++++++++----------
 tasks/uninstallv1.yml   |  6 +++---
 8 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/README.md b/README.md
index e9fdaba..88f910d 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/defaults/main.yml b/defaults/main.yml
index 5eb3342..8dca84e 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -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
diff --git a/handlers/main.yml b/handlers/main.yml
index a69488a..bc20262 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -1,12 +1,12 @@
 ---
 # 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
diff --git a/tasks/apache.yml b/tasks/apache.yml
index 803886a..cb7ab36 100644
--- a/tasks/apache.yml
+++ b/tasks/apache.yml
@@ -1,13 +1,13 @@
 ---
 # 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"
diff --git a/tasks/main.yml b/tasks/main.yml
index 70a60e6..cef1b35 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,13 +1,15 @@
 ---
 # 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
diff --git a/tasks/mysql.yml b/tasks/mysql.yml
index 0288eab..913801b 100644
--- a/tasks/mysql.yml
+++ b/tasks/mysql.yml
@@ -1,13 +1,13 @@
 ---
 # 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
diff --git a/tasks/serverdensity.yml b/tasks/serverdensity.yml
index daa9b2a..a465bbc 100644
--- a/tasks/serverdensity.yml
+++ b/tasks/serverdensity.yml
@@ -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"
 
diff --git a/tasks/uninstallv1.yml b/tasks/uninstallv1.yml
index d1982d9..65ed522 100644
--- a/tasks/uninstallv1.yml
+++ b/tasks/uninstallv1.yml
@@ -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
-- 
GitLab