From 217253e4ff4e445f599451f280eaa855fbd4275f Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Mon, 10 Jun 2019 20:20:06 +0200 Subject: [PATCH] ansible-playbooks/general#85 Linting [skip-ci] --- handlers/main.yml | 12 +++---- tasks/apache.yml | 57 ++++++++++++++++++-------------- tasks/mysql.yml | 24 +++++++------- tasks/serverdensity.yml | 72 +++++++++++++++++++++-------------------- tasks/uninstallv1.yml | 18 +++++------ 5 files changed, 97 insertions(+), 86 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index bc20262..c92f54e 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,12 +1,12 @@ --- # file: roles/serverdensity/handlers/main.yml -- name: ServerDensity | Restart Agent +- name: Restart Agent service: - name=sd-agent - state=restarted + name: sd-agent + state: restarted -- name: ServerDensity | Restart Apache +- name: Restart Apache service: - name=apache2 - state=restarted + name: apache2 + state: restarted diff --git a/tasks/apache.yml b/tasks/apache.yml index cb7ab36..313ad32 100644 --- a/tasks/apache.yml +++ b/tasks/apache.yml @@ -1,38 +1,45 @@ --- # file: roles/serverdensity/tasks/apache.yml -- name: ServerDensity | Apache | Install The Agent +- name: Install The Agent apt: - pkg=sd-agent-apache - state=present - notify: "ServerDensity | Restart Agent" + pkg: sd-agent-apache + state: present + notify: + - Restart Agent -- name: ServerDensity | Apache | Configure The Agent +- name: Configure The Agent template: - src=apache.yaml - dest=/etc/sd-agent/conf.d/apache.yaml - owner=root - group=root - mode='644' - notify: "ServerDensity | Restart Agent" + src: apache.yaml + dest: /etc/sd-agent/conf.d/apache.yaml + owner: root + group: root + mode: 0644 + notify: + - Restart Agent -- name: ServerDensity | Apache | Enable some required modules +- name: Enable some required modules apache2_module: - name={{ item }} - state=present + name: '{{ item }}' + state: present with_items: - status - notify: "ServerDensity | Restart Apache" + notify: + - Restart Apache -- name: ServerDensity | Apache | Configuration file for ServerDensity +- name: Configuration file for ServerDensity template: - src=etc-apache2-sites-available-sd-agent - dest=/etc/apache2/sites-available/sd-agent{{ apache_conf_ext|default('.conf') }} - owner=root - group=root - mode='644' - notify: "ServerDensity | Restart Apache" + src: etc-apache2-sites-available-sd-agent + dest: /etc/apache2/sites-available/sd-agent{{ apache_conf_ext|default('.conf') }} + owner: root + group: root + mode: 0644 + notify: + - Restart Apache -- 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" +- name: Enable the sd-agent site + command: a2ensite sd-agent + args: + creates: /etc/apache2/sites-enabled/sd-agent{{ apache_conf_ext|default('.conf') }} + notify: + - Restart Apache diff --git a/tasks/mysql.yml b/tasks/mysql.yml index 913801b..910be71 100644 --- a/tasks/mysql.yml +++ b/tasks/mysql.yml @@ -1,17 +1,19 @@ --- # file: roles/serverdensity/tasks/mysql.yml -- name: ServerDensity | MySQL | Install The Agent +- name: Install The Agent apt: - pkg=sd-agent-mysql - state=present - notify: "ServerDensity | Restart Agent" + pkg: sd-agent-mysql + state: present + notify: + - Restart Agent -- name: ServerDensity | MySQL | Configure The Agent +- name: Configure The Agent template: - src=mysql.yaml - dest=/etc/sd-agent/conf.d/mysql.yaml - owner=root - group=root - mode='644' - notify: "ServerDensity | Restart Agent" + src: mysql.yaml + dest: /etc/sd-agent/conf.d/mysql.yaml + owner: root + group: root + mode: 0644 + notify: + - Restart Agent diff --git a/tasks/serverdensity.yml b/tasks/serverdensity.yml index a465bbc..5c02d2c 100644 --- a/tasks/serverdensity.yml +++ b/tasks/serverdensity.yml @@ -4,59 +4,61 @@ - import_tasks: uninstallv1.yml when: sd_uninstallv1 -- name: ServerDensity | Init SD plugin - local_action: - serverdensity - api_token={{ sd_api_token }} - cleanup={{ sd_alert_cleanup }} - force={{ sd_force_update }} - cache={{ sd_api_cache_file }} +- name: Init SD plugin + local_action: serverdensity + api_token: '{{ sd_api_token }}' + cleanup: '{{ sd_alert_cleanup }}' + force: '{{ sd_force_update }}' + cache: '{{ sd_api_cache_file }}' when: sd_update_remote -- name: ServerDensity | Install Public Repo Key +- name: Install Public Repo Key apt_key: - url={{ sd_repo_public_key_uri }} - state=present + url: '{{ sd_repo_public_key_uri }}' + state: present -- name: ServerDensity | Add ServerDensity Repository To Apt +- name: 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' + content: deb http://archive.serverdensity.com/ubuntu/ all main + dest: /etc/apt/sources.list.d/sd-agent.list + mode: 0644 -- name: ServerDensity | Install The Agent +- name: Install The Agent apt: - pkg=sd-agent - state=present - update_cache=yes - notify: "ServerDensity | Restart Agent" + pkg: sd-agent + state: present + update_cache: yes + notify: + - Restart Agent -- name: ServerDensity | Create Plugins Directory +- name: Create Plugins Directory file: - dest={{ sd_agent_plugins_dir }} - state=directory - mode='755' + dest: '{{ sd_agent_plugins_dir }}' + state: directory + mode: 0755 -- name: ServerDensity | Copy Plugins +- name: Copy Plugins copy: - src={{ sd_plugins_files_dir }}/{{ item }} - dest={{ sd_agent_plugins_dir }}/{{ item }} + src: '{{ sd_plugins_files_dir }}/{{ item }}' + dest: '{{ sd_agent_plugins_dir }}/{{ item }}' with_items: '{{ sd_plugins|default([]) }}' - notify: "ServerDensity | Restart Agent" + notify: + - Restart Agent -- name: ServerDensity | Configure The Agent +- name: Configure The Agent template: - src={{ item }} - dest=/etc/sd-agent/{{ item }} - owner=root - group=root - mode='644' + src: '{{ item }}' + dest: '/etc/sd-agent/{{ item }}' + owner: root + group: root + mode: 0644 with_items: - config.cfg - plugins.cfg - #- supervisor.conf + # - supervisor.conf when: sd_agent_key != '' - notify: "ServerDensity | Restart Agent" + notify: + - Restart Agent - import_tasks: apache.yml when: sd_groups.apache != 'none' and inventory_hostname in groups[sd_groups.apache] diff --git a/tasks/uninstallv1.yml b/tasks/uninstallv1.yml index 65ed522..c6e3741 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: Stop v1 Agent service: - name=sd-agent - state=stopped + name: sd-agent + state: stopped # Uninstall agent -- name: ServerDensity | Uninstall v1 Agent +- name: Uninstall v1 Agent apt: - pkg=sd-agent - state=absent + pkg: sd-agent + state: absent # Remove /usr/bin/sd-agent -- name: ServerDensity | Remove Plugins Directory +- name: Remove Plugins Directory file: - dest=/usr/bin/sd-agent - state=absent + dest: /usr/bin/sd-agent + state: absent -- GitLab