From 350575e932fece4c58ff74967075283097f17704 Mon Sep 17 00:00:00 2001
From: Chris Croome <chris@webarchitects.co.uk>
Date: Wed, 1 May 2024 12:33:31 +0100
Subject: [PATCH] fix for remote nodes

---
 .gitlab-ci.yml          | 11 +----------
 .pre-commit-config.yaml |  4 ++--
 tasks/master_agents.yml |  8 ++++++--
 3 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4be03d5..f01606d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -30,21 +30,12 @@ before_script:
   - which molecule
   - molecule --version
 stages:
-  - lint
   - bookworm
-  # - bullseye
 bookworm:
-  image: registry.git.coop/webarch/containers/images/bookworm:20240209
+  image: registry.git.coop/webarch/containers/images/bookworm:20240426
   stage: bookworm
   script:
     - pre-commit install
     - pre-commit run --all-files
     - molecule test --all
-# The Bullseye test run OK but Molecule never completes
-# https://github.com/ansible/molecule/discussions/4020
-# bullseye:
-#   image: registry.git.coop/webarch/containers/images/bullseye:20240209
-#   stage: bullseye
-#   script:
-#     - molecule test
 ...
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a5208e7..1893899 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -25,7 +25,7 @@ repos:
           - templates
   # https://github.com/jackdewinter/pymarkdown/releases
   - repo: https://github.com/jackdewinter/pymarkdown.git
-    rev: v0.9.18
+    rev: v0.9.19
     hooks:
       - id: pymarkdown
         name: Markdown Lint
@@ -34,7 +34,7 @@ repos:
           - README.md
   # https://github.com/ansible/ansible-lint/releases
   - repo: https://github.com/ansible/ansible-lint.git
-    rev: v24.2.2
+    rev: v24.2.3
     hooks:
       - id: ansible-lint
         name: Ansible Lint
diff --git a/tasks/master_agents.yml b/tasks/master_agents.yml
index b95b206..f503233 100644
--- a/tasks/master_agents.yml
+++ b/tasks/master_agents.yml
@@ -115,13 +115,17 @@
       tags:
         - icinga
 
-    - name: Loop though the agent node hosts including tasks to generate a config file for each
+    - name: Loop though the agent node hosts including tasks to generate a config file for each host in the current play plus and remote hosts
       ansible.builtin.include_tasks: host.yml
       loop: "{{ icinga_agent_node_hosts_required }}"
       loop_control:
         loop_var: icinga_host
         label: "{{ icinga_host }}"
-      when: icinga_host in ansible_play_hosts
+      when: >-
+        ( icinga_host in ansible_play_hosts ) or
+        ( ( groups['icinga_remote_nodes'] is defined ) and
+        ( groups['icinga_remote_nodes'] != [] ) and
+        ( icinga_host in groups['icinga_remote_nodes'] ) )
 
     # TODO
     # - name: Check that agent node hosts are connected
-- 
GitLab