Skip to content
Snippets Groups Projects
Commit a2de184a authored by Rémi - Le Filament's avatar Rémi - Le Filament
Browse files

[UPD] ansible-lint

parent 35f8aaee
No related branches found
No related tags found
No related merge requests found
---
warn_list: # or 'skip_list' to silence them completely
- git-latest # Git checkouts must contain explicit version
- ignore-errors # Use failed_when and specify error conditions instead of using ignore_errors
- no-changed-when # Commands should not change things if nothing needs doing
- no-handler # Tasks that run when changed should likely be handlers
- package-latest # Package installs should not use latest
---
# Based on ansible-lint config
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
# comments enable
comments: enable
comments-indentation: enable
document-start: enable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation:
level: warning
indent-sequences: consistent
spaces: 4
check-multi-line-strings: true
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: enable
new-lines:
type: unix
# trailing-spaces enable
trailing-spaces: enable
truthy: enable
--- ---
- name: restart nrpe - name: Restart nrpe
service: ansible.builtin.service:
name: nagios-nrpe-server name: nagios-nrpe-server
state: restarted state: restarted
--- ---
galaxy_info: galaxy_info:
author: Rémi author: lefilament
description: This roles deploys Nagios NRPE on every host for monitoring from Nagios description: This roles deploys Nagios NRPE on every host for monitoring from Nagios
company: Le Filament (https://le-filament.com) company: Le Filament (https://le-filament.com)
license: AGPL-3.0-or-later license: AGPL-3.0-or-later
min_ansible_version: 2.1 min_ansible_version: "2.1"
platforms: platforms:
- name: EL - name: EL
versions: versions:
- 7 - "7"
- name: Ubuntu - name: Ubuntu
versions: versions:
- trusty - trusty
......
--- ---
- name: Include OS-specific variables. - name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml" ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
- name: Install NRPE and basic plugins - name: Install NRPE and basic plugins
package: ansible.builtin.package:
name: name:
- nagios-nrpe-server - nagios-nrpe-server
- monitoring-plugins-basic - monitoring-plugins-basic
state: present state: present
- name: Make NRPE start with system - name: Make NRPE start with system
service: ansible.builtin.service:
name: nagios-nrpe-server name: nagios-nrpe-server
state: started state: started
enabled: true enabled: true
...@@ -19,50 +19,52 @@ ...@@ -19,50 +19,52 @@
# CONFIGURATION NRPE # CONFIGURATION NRPE
# -------------------------------------------------- # --------------------------------------------------
- name: Push NRPE configuration file - name: Push NRPE configuration file
template: ansible.builtin.template:
src: nrpe.cfg.j2 src: nrpe.cfg.j2
dest: /etc/nagios/nrpe.cfg dest: /etc/nagios/nrpe.cfg
owner: root owner: root
group: root group: root
mode: '0644' mode: '0644'
notify: restart nrpe notify: Restart nrpe
tags: nrpe_config tags: nrpe_config
# -------------------------------------------------- # --------------------------------------------------
# AJOUT CUSTOM SCRIPTs # AJOUT CUSTOM SCRIPTs
# -------------------------------------------------- # --------------------------------------------------
- name: create custom-plugin repo if not created from previous tasks - name: Create custom-plugin repo if not created from previous tasks
file: ansible.builtin.file:
name: /usr/lib/nagios/custom-plugins name: /usr/lib/nagios/custom-plugins
state: directory state: directory
owner: root owner: root
group: root group: root
mode: '0755' mode: '0755'
- name: get custom scripts from gitlab - name: Get custom scripts from gitlab
git: ansible.builtin.git:
repo: "https://sources.le-filament.com/lefilament/nagios-plugin.git" repo: "https://sources.le-filament.com/lefilament/nagios-plugin.git"
dest: "/usr/lib/nagios/custom-plugins" dest: "/usr/lib/nagios/custom-plugins"
version: "master" version: "master"
when: inventory_hostname in groups.backup_server when: inventory_hostname in groups.backup_server
- name: set file rights on custom plugins - name: Set file rights on custom plugins
file: name={{ item }} mode=0555 ansible.builtin.file:
name: "{{ item }}"
mode: 0555
with_items: with_items:
- /usr/lib/nagios/custom-plugins/check_cloud_storage.sh - /usr/lib/nagios/custom-plugins/check_cloud_storage.sh
- /usr/lib/nagios/custom-plugins/check_odoo_storage.sh - /usr/lib/nagios/custom-plugins/check_odoo_storage.sh
- /usr/lib/nagios/custom-plugins/check_odoo2_storage.sh - /usr/lib/nagios/custom-plugins/check_odoo2_storage.sh
when: inventory_hostname in groups.backup_server when: inventory_hostname in groups.backup_server
- name: add check_mdstat script - name: Add check_mdstat script
get_url: ansible.builtin.get_url:
url: https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=5423&cf_id=24 url: https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=5423&cf_id=24
dest: /usr/lib/nagios/custom-plugins/check_mdstat.sh dest: /usr/lib/nagios/custom-plugins/check_mdstat.sh
mode: '0555' mode: '0555'
when: raid_config is defined when: raid_config is defined
- name: add extra scripts - name: Add extra scripts
get_url: ansible.builtin.get_url:
url: "{{ item.url }}" url: "{{ item.url }}"
dest: /usr/lib/nagios/custom-plugins/{{ item.name }} dest: /usr/lib/nagios/custom-plugins/{{ item.name }}
mode: '0555' mode: '0555'
...@@ -70,15 +72,15 @@ ...@@ -70,15 +72,15 @@
loop_control: loop_control:
label: "{{ item.name }}" label: "{{ item.name }}"
- name: add nagios to www-data group - name: Add nagios to www-data group
user: ansible.builtin.user:
name: nagios name: nagios
groups: www-data groups: www-data
append: true append: true
when: inventory_hostname in groups.owncloud_server | union(groups.docker_owncloud) | union(groups.docker_nextcloud) when: inventory_hostname in groups.owncloud_server | union(groups.docker_owncloud) | union(groups.docker_nextcloud)
- name: add cron job to update available packages every day - name: Add cron job to update available packages every day
cron: ansible.builtin.cron:
name: apt update name: apt update
minute: "42" minute: "42"
hour: "7" hour: "7"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment