From 096655a6c1d5b8d7cc0db1970649efdb95e1cbf9 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Fri, 21 Feb 2025 07:13:00 +1300 Subject: [PATCH] =?UTF-8?q?fix:=20Use=20local=5Faction=20to=20ensure=20run?= =?UTF-8?q?s=20on=20controller=20=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/host-management.yml | 3 ++- tasks/host-management/modern.yml | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tasks/host-management.yml b/tasks/host-management.yml index 38890d0..93a0a8a 100644 --- a/tasks/host-management.yml +++ b/tasks/host-management.yml @@ -1,6 +1,7 @@ --- - name: Retrieve checkmk version - uri: + local_action: + module: uri method: GET headers: Authorization: Bearer {{ cmk_username }} {{ cmk_secret }} diff --git a/tasks/host-management/modern.yml b/tasks/host-management/modern.yml index f4ef2d1..51c7233 100644 --- a/tasks/host-management/modern.yml +++ b/tasks/host-management/modern.yml @@ -1,6 +1,7 @@ --- - name: add host to omd (new) - uri: + local_action: + module: uri method: POST headers: Authorization: Bearer {{ cmk_username }} {{ cmk_secret }} @@ -18,7 +19,6 @@ status_code: [200, 400] register: res_add become: false - delegate_to: localhost when: > cmk_add_host and cmk_major | int >= 2 and cmk_minor | int >= 2 @@ -28,7 +28,9 @@ when: cmk_add_host - name: Host exists fetch etag (new) # noqa command-instead-of-module - shell: | + local_action: + module: shell + cmd: | curl \ -G \ -i \ @@ -39,7 +41,6 @@ "{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/api/v0/objects/host_config/{{ inventory_hostname | upper }}" register: res_host_exists become: false - delegate_to: localhost when: > cmk_add_host and (cmk_major | int >= 2 and cmk_minor | int >= 2) and (res_add.status == 400 and output.fields.host_name | first | regex_search('already @@ -54,7 +55,8 @@ exists.$')) - name: Update host as already exists? (new) - uri: + local_action: + module: uri method: PUT headers: Authorization: Bearer {{ cmk_username }} {{ cmk_secret }} @@ -70,7 +72,6 @@ status_code: [200] register: res become: false - delegate_to: localhost when: > cmk_add_host and (cmk_major | int >= 2 and cmk_minor | int >= 2) and (res_add.status == 400 and output.fields.host_name | first | regex_search('already @@ -82,7 +83,8 @@ when: cmk_add_host - name: cmk_discovery (new) - uri: + local_action: + module: uri method: POST headers: Authorization: Bearer {{ cmk_username }} {{ cmk_secret }} @@ -98,10 +100,10 @@ cmk_add_host and cmk_major | int >= 2 and cmk_minor | int >= 2 or cmk_force_install - delegate_to: localhost - name: cmk_apply (new) - uri: + local_action: + module: uri method: POST headers: Authorization: Bearer {{ cmk_username }} {{ cmk_secret }} @@ -120,4 +122,3 @@ when: > cmk_add_host and cmk_major | int >= 2 and cmk_minor | int >= 2 or cmk_force_install - delegate_to: localhost