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