Skip to content

Commit

Permalink
Lint again: ansible-lint 6.17.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sdarwin committed Jul 6, 2023
1 parent e2eab40 commit 3a10d3a
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 102 deletions.
96 changes: 48 additions & 48 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@ nrpe_plugin_dir: /usr/lib/nagios/plugins
# Directory that will be used as the location for the downloads§
nagios_download_dir: "{{ ansible_env.HOME }}/nagios"

nagios_admins_group: 'sysadmin'
nagios_admins_group: sysadmin
# nagios_users_group: 'users'

nagios_version: 4.4.9
nagios_plugins_version: 2.4.4
nrpe_version: 4.0.3

# Define the download url for the Nagios Core source files and the version you want to use.
nagios_url: "https://assets.nagios.com/downloads/nagioscore/releases/nagios-{{ nagios_version }}.tar.gz"
nagios_url: https://assets.nagios.com/downloads/nagioscore/releases/nagios-{{ nagios_version }}.tar.gz

# This is the directory where the Nagios source files will be placed, this should be
# the directory which is created when the download file is unpacked when runnint
# tar -xzvf nagios-4.1.1.tar.gz
nagios_src: "nagios-{{ nagios_version }}"
nagios_src: nagios-{{ nagios_version }}

# Define the download url for the Plugins and the version you want to use.
nagios_pluginsurl: "http://www.nagios-plugins.org/download/nagios-plugins-{{ nagios_plugins_version }}.tar.gz"
nagios_pluginsurl: http://www.nagios-plugins.org/download/nagios-plugins-{{ nagios_plugins_version }}.tar.gz
# This is the directory where the Plugin source files will be placed, this should be
# the directory which is created when the download file is unpacked when runnint
# tar -xzvf nagios-plugins-2.1.1.tar.gz
nagios_pluginssrc: "nagios-plugins-{{ nagios_plugins_version }}"
nagios_pluginssrc: nagios-plugins-{{ nagios_plugins_version }}

nagios_monitoring_user: nagios
nagios_monitoring_command_group: nagcmd
Expand All @@ -45,8 +45,8 @@ nagios_users:
# require the distributions Nagios package to be installed.
# nrpe_url: "http://sourceforge.net/projects/nagios/files/nrpe-{{ nrpe_version | regex_replace('(\\d+)\\..*', '\\1') }}.x/nrpe-{{ nrpe_version }}/nrpe-{{ nrpe_version }}.tar.gz"
# nrpe_url: "https://downloads.sourceforge.net/project/nagios/nrpe-{{ nrpe_version | regex_replace('(\\d+)\\..*', '\\1') }}.x/nrpe-{{ nrpe_version }}.tar.gz"
nrpe_url: "https://downloads.sourceforge.net/project/nagios/nrpe-{{ nrpe_version | regex_replace('(\\d+)\\..*', '\\1') }}.x//nrpe-{{ nrpe_version }}/nrpe-{{ nrpe_version }}.tar.gz"
nrpe_src: "nrpe-{{ nrpe_version }}"
nrpe_url: https://downloads.sourceforge.net/project/nagios/nrpe-{{ nrpe_version | regex_replace('(\d+)\..*', '\1') }}.x//nrpe-{{ nrpe_version }}/nrpe-{{ nrpe_version }}.tar.gz
nrpe_src: nrpe-{{ nrpe_version }}

# Location of monitoring plugins
nrpe_client_plugins_dir: /usr/local/nagios/libexec
Expand All @@ -71,13 +71,13 @@ nagios_group: nagios

# define service checks per hostgroup here. Groups themselves are created by the ansible inventory.
nagios_host_groups:
- name: 'all'
- name: all
checks:
- {command: 'check_ssh', description: 'SSH Service Check'}
- {command: 'check_disk', description: 'Check Disk Space'}
- {command: check_ssh, description: SSH Service Check}
- {command: check_disk, description: Check Disk Space}
# - {command: 'check_swap', description: 'Check Swap Space'}
- {command: 'check_load', description: 'Check Load'}
- {command: 'check_mem', description: 'Check Memory'}
- {command: check_load, description: Check Load}
- {command: check_mem, description: Check Memory}
# - name: 'webservers'
# checks:
# - {command: 'check_http', description: 'Check HTTP'}
Expand All @@ -92,28 +92,28 @@ nagios_hosts: ""
nagios_commands:
# check_ssh is already in the default installation
# - {name: 'check_ssh', command: '$USER1$/check_ssh $ARG1$ $HOSTADDRESS$'}
- {name: 'check_disk', command: '$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_disk'}
- {name: 'check_load', command: '$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load'}
- {name: 'check_swap', command: '$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_swap'}
- {name: 'check_mem', command: '$USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mem'}
- {name: 'check_https', command: '$USER1$/check_http -f follow -S --verify-host -C 21,14 --continue-after-certificate --sni -I $ARG1$ -H $ARG2$ -s $ARG3$ -u $ARG4$'}
- {name: 'check_https_certonly', command: '$USER1$/check_http -f follow -S --verify-host -C 21,14 --sni -I $ARG1$ -H $ARG2$ -s $ARG3$ -u $ARG4$ -p $ARG5$'}
- {name: 'check_http_full', command: '$USER1$/check_http -f follow --sni -I $ARG1$ -H $ARG2$ -s $ARG3$ -u $ARG4$'}
- {name: check_disk, command: $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_disk}
- {name: check_load, command: $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load}
- {name: check_swap, command: $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_swap}
- {name: check_mem, command: $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_mem}
- {name: check_https, command: "$USER1$/check_http -f follow -S --verify-host -C 21,14 --continue-after-certificate --sni -I $ARG1$ -H $ARG2$ -s $ARG3$ -u $ARG4$"}
- {name: check_https_certonly, command: "$USER1$/check_http -f follow -S --verify-host -C 21,14 --sni -I $ARG1$ -H $ARG2$ -s $ARG3$ -u $ARG4$ -p $ARG5$"}
- {name: check_http_full, command: $USER1$/check_http -f follow --sni -I $ARG1$ -H $ARG2$ -s $ARG3$ -u $ARG4$}

nagios_cgi_show_context_help: 1
nagios_cgi_authorized_for_system_information: '*'
nagios_cgi_authorized_for_configuration_information: '*'
nagios_cgi_authorized_for_system_commands: '*'
nagios_cgi_authorized_for_all_services: '*'
nagios_cgi_authorized_for_all_hosts: '*'
nagios_cgi_authorized_for_all_service_commands: '*'
nagios_cgi_authorized_for_all_host_commands: '*'
nagios_cgi_authorized_for_system_information: "*"
nagios_cgi_authorized_for_configuration_information: "*"
nagios_cgi_authorized_for_system_commands: "*"
nagios_cgi_authorized_for_all_services: "*"
nagios_cgi_authorized_for_all_hosts: "*"
nagios_cgi_authorized_for_all_service_commands: "*"
nagios_cgi_authorized_for_all_host_commands: "*"
nagios_cgi_default_statusmap_layout: 5
nagios_cgi_default_statuswrl_layout: 4
nagios_cgi_result_limit: 100
nagios_cgi_escape_html_tags: 0
nagios_cgi_action_url_target: '_blank'
nagios_cgi_notes_url_target: '_blank'
nagios_cgi_action_url_target: _blank
nagios_cgi_notes_url_target: _blank
nagios_cgi_lock_author_names: 1
nagios_server_name: nagios
nagios_conf_dir: "{{ nagios_base_dir }}/etc"
Expand All @@ -132,17 +132,17 @@ nrpe_checks:
critical_condition: "{{ ansible_processor_vcpus * 2 }},{{ ansible_processor_vcpus * 3 / 2 }},{{ ansible_processor_vcpus }}"
check_disk:
command: "{{ nrpe_plugin_dir }}/check_disk"
warning_condition: '20%'
critical_condition: '10%'
parameters: "-A -i '.gvfs' -i /run/user -i /run/lxcfs -i /run/docker -i /var/lib/docker -i /var/lib/kubelet -i '/snap/*' -i /sys/kernel/debug/tracing"
warning_condition: 20%
critical_condition: 10%
parameters: -A -i '.gvfs' -i /run/user -i /run/lxcfs -i /run/docker -i /var/lib/docker -i /var/lib/kubelet -i '/snap/*' -i /sys/kernel/debug/tracing
check_swap:
command: "{{ nrpe_plugin_dir }}/check_swap"
warning_condition: '30%'
critical_condition: '20%'
warning_condition: 30%
critical_condition: 20%
check_mem:
command: "{{ nrpe_plugin_dir }}/check_mem"
warning_condition: '70'
critical_condition: '80'
warning_condition: "70"
critical_condition: "80"

nagios_hosts_ignore: ""
nagios_groups_ignore: ""
Expand All @@ -157,7 +157,7 @@ nagios_allowed_hosts:
nagios_remove_all_group: "no"

# Probably leave this as-is. It should match your top-level ansible playbook, such as "- hosts: monitoring-servers"
nagios_monitoring_servers_group_name: "monitoring-servers"
nagios_monitoring_servers_group_name: monitoring-servers

# optionally define more timeperiods.
nagios_timeperiods: ""
Expand All @@ -173,20 +173,20 @@ nagios_timeperiods: ""
# saturday: "00:00-06:00,06:15-07:00,07:15-08:00,08:15-24:00"
#

nsclient_installed_location: 'C:\\Program Files\\NSClient++'
nsclient_password: 'Pi4j8ZWcUZdecYQu'
nsclient_installed_location: C:\\Program Files\\NSClient++
nsclient_password: Pi4j8ZWcUZdecYQu
# using nagios_allowed_hosts instead of nsclient_allowed_hosts
# nsclient_allowed_hosts: '127.0.0.1'
nsclient_ssl_options: 'no-sslv2,no-sslv3'
nsclient_verify_mode: 'none'
nsclient_insecure: 'false'
nsclient_checkexternalscripts: 'enabled'
nsclient_checkhelpers: 'disabled'
nsclient_checkeventlog: 'disabled'
nsclient_checknscp: 'disabled'
nsclient_checkdisk: 'enabled'
nsclient_checksystem: 'enabled'
nsclient_nrpeserver: 'enabled'
nsclient_ssl_options: no-sslv2,no-sslv3
nsclient_verify_mode: none
nsclient_insecure: "false"
nsclient_checkexternalscripts: enabled
nsclient_checkhelpers: disabled
nsclient_checkeventlog: disabled
nsclient_checknscp: disabled
nsclient_checkdisk: enabled
nsclient_checksystem: enabled
nsclient_nrpeserver: enabled
# replace this with new output from 'openssl dhparam -C 2048'
# hopefully the standard installer will include the step soon
nsclient_nrpe_dh_2048_pem: |
Expand Down
1 change: 1 addition & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
state: restarted

- name: Restart nrpe osx
changed_when: false
ansible.builtin.shell: |
/bin/launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nrpe.plist
/usr/bin/pkill -f /usr/local/opt/nrpe/bin/nrpe
Expand Down
12 changes: 6 additions & 6 deletions tasks/build-nagios.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---

- name: GET Nagios
ansible.builtin.get_url:
url: "{{ nagios_url }}"
dest: "{{ nagios_download_dir }}/{{ nagios_src }}.tar.gz"
mode: 0755
mode: "0755"

- name: Unpack Nagios source files
ansible.builtin.shell: cd {{ nagios_download_dir }} && tar -xzvf {{ nagios_src }}.tar.gz creates={{ nagios_download_dir }}/{{ nagios_src }}
Expand Down Expand Up @@ -54,6 +53,7 @@

- name: Make install-init
ansible.builtin.shell: cd {{ nagios_download_dir }}/{{ nagios_src }} && make install-init
changed_when: true
when:
- not init_d_nagios_stat.stat.exists
- not nagios_service_stat.stat.exists
Expand All @@ -70,8 +70,8 @@
line: "{{ item.line }}"
insertbefore: "### END INIT INFO"
with_items:
- {regexp: '^# Default-Start:\s*2 3 4 5', line: '# Default-Start: 2 3 4 5'}
- {regexp: '^# Default-Stop:\s*0 1 6', line: '# Default-Stop: 0 1 6'}
- {regexp: ^# Default-Start:\s*2 3 4 5, line: "# Default-Start: 2 3 4 5"}
- {regexp: ^# Default-Stop:\s*0 1 6, line: "# Default-Stop: 0 1 6"}
when: init_d_nagios_stat_2.stat.exists

- name: Set htpasswd for gui users
Expand All @@ -82,7 +82,7 @@
state: present
owner: root
group: root
mode: 0644
mode: "0644"
with_items: "{{ nagios_users | default([]) }}"
no_log: true

Expand All @@ -95,7 +95,7 @@
state: present
owner: root
group: root
mode: 0644
mode: "0644"
when: nagios_admins_group in item.groups
with_items: "{{ users | default([]) }}"
no_log: true
Expand Down
2 changes: 1 addition & 1 deletion tasks/build-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ansible.builtin.get_url:
url: "{{ nagios_pluginsurl }}"
dest: "{{ nagios_download_dir }}/{{ nagios_pluginssrc }}.tar.gz"
mode: 0755
mode: "0755"

- name: Unpack Plugin source files
ansible.builtin.shell: cd {{ nagios_download_dir }} && tar -xzvf {{ nagios_pluginssrc }}.tar.gz creates={{ nagios_download_dir }}/{{ nagios_pluginssrc }}
Expand Down
1 change: 0 additions & 1 deletion tasks/client.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Include linux client
ansible.builtin.import_tasks: client_linux.yml
when: ansible_system == 'Linux'
Expand Down
8 changes: 4 additions & 4 deletions tasks/client_freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
dest: /usr/local/etc/nrpe.cfg
owner: root
group: wheel
mode: 0644
mode: "0644"
notify: Restart nrpe

- name: Enable nrpe3 in /etc/rc.conf
ansible.builtin.lineinfile:
path: /etc/rc.conf
regexp: '^nrpe3_enable='
regexp: ^nrpe3_enable=
line: nrpe3_enable="YES"

# how to monitor memory on freebsd?
Expand All @@ -34,15 +34,15 @@
state: directory
owner: root
group: wheel
mode: 0755
mode: "0755"

- name: NRPE checks
ansible.builtin.template:
src: nrpe_check.cfg
dest: "{{ nrpe_conf_dir }}/nrpe.d/{{ item.key }}.cfg"
owner: root
group: wheel
mode: 0644
mode: "0644"
with_dict: "{{ nrpe_checks }}"
notify: Restart nrpe

Expand Down
8 changes: 4 additions & 4 deletions tasks/client_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
ansible.builtin.copy:
src: files/check_mem
dest: "{{ nrpe_plugin_dir }}/check_mem"
mode: '0755'
mode: "0755"

- name: NRPE config file
ansible.builtin.template:
src: nrpe.cfg
dest: /etc/nagios/nrpe.cfg
owner: root
group: root
mode: 0644
mode: "0644"
notify: Restart nrpe

# for redhat
Expand All @@ -99,14 +99,14 @@
state: directory
owner: root
group: root
mode: 0755
mode: "0755"

- name: NRPE checks
ansible.builtin.template:
src: nrpe_check.cfg
dest: "{{ nrpe_conf_dir }}/nrpe.d/{{ item.key }}.cfg"
owner: root
group: root
mode: 0644
mode: "0644"
with_dict: "{{ nrpe_checks }}"
notify: Restart nrpe
17 changes: 9 additions & 8 deletions tasks/client_macos.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: Set fact nagios_mac_install_base
ansible.builtin.set_fact:
nagios_mac_install_base: "/usr/local"
nagios_mac_install_base: /usr/local

- name: Set fact nagios_mac_install_base arm64
ansible.builtin.set_fact:
nagios_mac_install_base: "/opt/homebrew"
nagios_mac_install_base: /opt/homebrew
when: ansible_architecture == "arm64"

- name: Ensure nrpe_group exists
Expand All @@ -16,7 +16,7 @@
- name: Ensure nrpe_user exists
ansible.builtin.user:
name: "{{ nrpe_user }}"
shell: "/bin/false"
shell: /bin/false
groups: "{{ nrpe_group }}"
append: true

Expand All @@ -34,14 +34,15 @@
- name: Install brew
ansible.builtin.command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
when: does_brew_exist.rc
changed_when: true

- name: Set fact nrpe_plugin_dir_default
ansible.builtin.set_fact:
nrpe_plugin_dir: "{{ nagios_mac_install_base }}/opt/nagios-plugins/libexec/sbin"

# Just ran into this problem. A conflict with prometheus.
# Might solve it another way in the future.
- name: Fix dir permissions # noqa deprecated-command-syntax
- name: Fix dir permissions # noqa no-free-form
ansible.builtin.shell: |
chmod g+w {{ nagios_mac_install_base }}/var/log
args:
Expand All @@ -67,7 +68,7 @@
dest: /Library/LaunchDaemons/homebrew.mxcl.nrpe.plist
owner: root
group: wheel
mode: 0755
mode: "0755"
notify: Restart nrpe osx

- name: Remove default LaunchDaemon config
Expand All @@ -85,7 +86,7 @@
dest: "{{ nagios_mac_install_base }}/etc/nrpe.cfg"
owner: administrator
group: admin
mode: 0644
mode: "0644"
notify: Restart nrpe osx

- name: Create nrpe.d dir
Expand All @@ -94,15 +95,15 @@
state: directory
owner: administrator
group: admin
mode: 0755
mode: "0755"

- name: NRPE checks
ansible.builtin.template:
src: nrpe_check.cfg
dest: "{{ nrpe_conf_dir }}/nrpe.d/{{ item.key }}.cfg"
owner: administrator
group: admin
mode: 0644
mode: "0644"
with_dict: "{{ nrpe_checks }}"
notify: Restart nrpe osx

Expand Down
Loading

0 comments on commit 3a10d3a

Please sign in to comment.