Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #30 - create cache dirs for local checks and plugins if required #31

Merged
merged 3 commits into from
Aug 26, 2024

Conversation

zerwes
Copy link
Contributor

@zerwes zerwes commented Aug 25, 2024

relates to issue #30

@crpb
Copy link
Contributor

crpb commented Aug 26, 2024

don't know how else but here goes. after those modifications it seems to work.

diff --git a/tasks/main.yml b/tasks/main.yml
index 132e3ca..304244f 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -60,7 +60,7 @@
     path: "{{ opn_check_mk_lib_dir }}/plugins/{{ item }}"
     state: directory
     mode: 0755
-  with_items: "{{ opn_check_mk_plugins | map('dirname') | unique |}}"
+  with_items: "{{ opn_check_mk_plugins | map('dirname') | unique }}"
   when:
     - opn_install_check_mk
     - item | length > 0
@@ -71,7 +71,9 @@
     dest: "{{ opn_check_mk_lib_dir }}/plugins/{{ item }}"
     mode: 0700
   with_items: "{{ opn_check_mk_plugins }}"
-  when: opn_install_check_mk
+  when:
+    - opn_install_check_mk
+    - item | length == 0
 
 - name: create check_mk local checks cache dirs
   ansible.builtin.file:
@@ -89,7 +91,9 @@
     dest: "{{ opn_check_mk_lib_dir }}/local/{{ item }}"
     mode: 0700
   with_items: "{{ opn_check_mk_local_checks }}"
-  when: opn_install_check_mk
+  when:
+    - opn_install_check_mk
+    - item | length == 0
 
 - name: copy check_mk additional files
   ansible.builtin.copy:

@crpb
Copy link
Contributor

crpb commented Aug 26, 2024

hmm.. moved stuff around now it isn't working anymore.. will get back to you.

@zerwes zerwes self-assigned this Aug 26, 2024
@zerwes zerwes added the enhancement New feature or request label Aug 26, 2024
@zerwes
Copy link
Contributor Author

zerwes commented Aug 26, 2024

Sorry @crpb
the | pipe at the end of the filter list was a half-baked thoughts; I wanted to ensure the result is a list.
fixed

@zerwes
Copy link
Contributor Author

zerwes commented Aug 26, 2024

Now the playbook should work with a simplified declaration like

opn_check_mk_local_checks:
    - 600/crash_status.py
    - 600/firmware_status.py
    - 600/pkg_audit.py
    - 600/pkg_check.sh
    - 600/check_powerunit.sh
    - gateways_status.py
    - pfctl_status.sh

opn_check_mk_plugins:
    - 60/wireguard

no need to add the directories first, they should be created

@zerwes
Copy link
Contributor Author

zerwes commented Aug 26, 2024

the filter opn_check_mk_plugins | map('dirname') | unique | list should give you ['600', '']

@crpb
Copy link
Contributor

crpb commented Aug 26, 2024

The current problem was the lookup of the files in the root of ./files/ and not in a subdirectory. /ó\

nevermind that.... wrong terminal for results..

@zerwes
Copy link
Contributor Author

zerwes commented Aug 26, 2024

The current problem was the lookup of the files in the root of ./files/ and not in a subdirectory

I could implement something like a first_found lookup for the src, so for example crash_status.py could be placed in files/600/ (I would prefer this way), but also in files/ ....

@crpb
Copy link
Contributor

crpb commented Aug 26, 2024

It was just a thought as you might have hosts that should run the check every half hour and others that are fine if that is run like only once a day.
So you won't need to copy the file to multiple locations but only define it with the directory as a var/host.

@zerwes
Copy link
Contributor Author

zerwes commented Aug 26, 2024

It was just a thought as you might have hosts that should run the check every half hour and others that are fine if that is run like only once a day. So you won't need to copy the file to multiple locations but only define it with the directory as a var/host.

sounds like a reasonable scenario

have a look at 52b3618 and let me know if it fits you needs

@crpb
Copy link
Contributor

crpb commented Aug 26, 2024

have a look at 52b3618 and let me know if it fits you needs

Yeah, that is looking good. it's filling again 🚀
image

@zerwes zerwes merged commit 3bbf534 into main Aug 26, 2024
4 checks passed
@zerwes
Copy link
Contributor Author

zerwes commented Aug 26, 2024

Thank you @crpb 👍

In general: looks like we have very similar scenarios ... opnsense in combination w/ checkmk, wireguard etc.
Would you mind exchanging some thoughts and ideas?

@crpb
Copy link
Contributor

crpb commented Aug 26, 2024

Sure. if you have irc, i'm on OFTC as cb and Libera as crpb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants