From d9ec7b879b64cc72e6fa8536fee4b8caf3d54c61 Mon Sep 17 00:00:00 2001 From: Terry Derks Date: Sun, 10 Dec 2023 20:23:00 -0500 Subject: [PATCH] install plugins on icinga master --- icinga2/init.sls | 1 + icinga2/plugins.sls | 42 +++++++++++++++++++++++++++++++++++++++ icinga2/ssh_client.sls | 45 ------------------------------------------ 3 files changed, 43 insertions(+), 45 deletions(-) create mode 100644 icinga2/plugins.sls diff --git a/icinga2/init.sls b/icinga2/init.sls index c346c37..a84c078 100644 --- a/icinga2/init.sls +++ b/icinga2/init.sls @@ -1,4 +1,5 @@ include: + - icinga2.plugins {% if salt.pillar.get("icinga2:ssh_client", None) is not none %} - icinga2.ssh_client {% endif %} diff --git a/icinga2/plugins.sls b/icinga2/plugins.sls new file mode 100644 index 0000000..3b53e26 --- /dev/null +++ b/icinga2/plugins.sls @@ -0,0 +1,42 @@ +# A deploy key must be added for this to work! +/usr/local/lib/nagios: + git.cloned: + - name: {{ salt.pillar.get("icinga2:monitoring_plugins_git_url") | yaml_encode }} + - target: /usr/local/lib/nagios + - branch: master + - user: root + +/usr/local/lib/nagios/venv: + cmd.run: +{% if 'inmotionhosting' in grains.fqdn %} + - name: imh-python3 -m venv /usr/local/lib/nagios/venv +{% else %} + - name: python3 -m venv /usr/local/lib/nagios/venv +{% endif %} + - creates: /usr/local/lib/nagios/venv + - require: + - git: /usr/local/lib/nagios + - pkg: monitoring_packages + +# TODO: make all this venv stuff a cmd.script + +venv-ensurepip: + cmd.run: + - name: /usr/local/lib/nagios/venv/bin/python3 -m ensurepip + - creates: /usr/local/lib/nagios/venv/bin/pip3 + - require: + - cmd: /usr/local/lib/nagios/venv + +venv-psutil: + cmd.run: + - name: /usr/local/lib/nagios/venv/bin/pip3 install psutil + - require: + - cmd: venv-ensurepip + +monitoring_packages: + pkg.installed: + - pkgs: + - smartmontools + {% if grains.os_family == 'Debian' %} + - python3-venv + {% endif %} diff --git a/icinga2/ssh_client.sls b/icinga2/ssh_client.sls index a7394dd..256c52e 100644 --- a/icinga2/ssh_client.sls +++ b/icinga2/ssh_client.sls @@ -1,48 +1,3 @@ - -# A deploy key must be added for this to work! -/usr/local/lib/nagios: - git.cloned: - - name: {{ salt.pillar.get("icinga2:monitoring_plugins_git_url") | yaml_encode }} - - target: /usr/local/lib/nagios - - branch: master - - user: root - - -/usr/local/lib/nagios/venv: - cmd.run: -{% if 'inmotionhosting' in grains.fqdn %} - - name: imh-python3 -m venv /usr/local/lib/nagios/venv -{% else %} - - name: python3 -m venv /usr/local/lib/nagios/venv -{% endif %} - - creates: /usr/local/lib/nagios/venv - - require: - - git: /usr/local/lib/nagios - - pkg: monitoring_packages - -# TODO: make all this venv stuff a cmd.script - -venv-ensurepip: - cmd.run: - - name: /usr/local/lib/nagios/venv/bin/python3 -m ensurepip - - creates: /usr/local/lib/nagios/venv/bin/pip3 - - require: - - cmd: /usr/local/lib/nagios/venv - -venv-psutil: - cmd.run: - - name: /usr/local/lib/nagios/venv/bin/pip3 install psutil - - require: - - cmd: venv-ensurepip - -monitoring_packages: - pkg.installed: - - pkgs: - - smartmontools - {% if grains.os_family == 'Debian' %} - - python3-venv - {% endif %} - icinga: user.present: - shell: /bin/bash