You've already forked ansible-role-checkmk-agent
fix: Use local_action to ensure runs on controller 🐛
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Retrieve checkmk version
|
- name: Retrieve checkmk version
|
||||||
uri:
|
local_action:
|
||||||
|
module: uri
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: add host to omd (new)
|
- name: add host to omd (new)
|
||||||
uri:
|
local_action:
|
||||||
|
module: uri
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||||
@@ -18,7 +19,6 @@
|
|||||||
status_code: [200, 400]
|
status_code: [200, 400]
|
||||||
register: res_add
|
register: res_add
|
||||||
become: false
|
become: false
|
||||||
delegate_to: localhost
|
|
||||||
when: >
|
when: >
|
||||||
cmk_add_host and cmk_major | int >= 2 and cmk_minor | int >= 2
|
cmk_add_host and cmk_major | int >= 2 and cmk_minor | int >= 2
|
||||||
|
|
||||||
@@ -28,7 +28,9 @@
|
|||||||
when: cmk_add_host
|
when: cmk_add_host
|
||||||
|
|
||||||
- name: Host exists fetch etag (new) # noqa command-instead-of-module
|
- name: Host exists fetch etag (new) # noqa command-instead-of-module
|
||||||
shell: |
|
local_action:
|
||||||
|
module: shell
|
||||||
|
cmd: |
|
||||||
curl \
|
curl \
|
||||||
-G \
|
-G \
|
||||||
-i \
|
-i \
|
||||||
@@ -39,7 +41,6 @@
|
|||||||
"{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/api/v0/objects/host_config/{{ inventory_hostname | upper }}"
|
"{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/api/v0/objects/host_config/{{ inventory_hostname | upper }}"
|
||||||
register: res_host_exists
|
register: res_host_exists
|
||||||
become: false
|
become: false
|
||||||
delegate_to: localhost
|
|
||||||
when: >
|
when: >
|
||||||
cmk_add_host and (cmk_major | int >= 2 and cmk_minor | int >= 2) and
|
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
|
(res_add.status == 400 and output.fields.host_name | first | regex_search('already
|
||||||
@@ -54,7 +55,8 @@
|
|||||||
exists.$'))
|
exists.$'))
|
||||||
|
|
||||||
- name: Update host as already exists? (new)
|
- name: Update host as already exists? (new)
|
||||||
uri:
|
local_action:
|
||||||
|
module: uri
|
||||||
method: PUT
|
method: PUT
|
||||||
headers:
|
headers:
|
||||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||||
@@ -70,7 +72,6 @@
|
|||||||
status_code: [200]
|
status_code: [200]
|
||||||
register: res
|
register: res
|
||||||
become: false
|
become: false
|
||||||
delegate_to: localhost
|
|
||||||
when: >
|
when: >
|
||||||
cmk_add_host and (cmk_major | int >= 2 and cmk_minor | int >= 2) and
|
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
|
(res_add.status == 400 and output.fields.host_name | first | regex_search('already
|
||||||
@@ -82,7 +83,8 @@
|
|||||||
when: cmk_add_host
|
when: cmk_add_host
|
||||||
|
|
||||||
- name: cmk_discovery (new)
|
- name: cmk_discovery (new)
|
||||||
uri:
|
local_action:
|
||||||
|
module: uri
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||||
@@ -98,10 +100,10 @@
|
|||||||
cmk_add_host and cmk_major | int >= 2 and
|
cmk_add_host and cmk_major | int >= 2 and
|
||||||
cmk_minor | int >= 2 or
|
cmk_minor | int >= 2 or
|
||||||
cmk_force_install
|
cmk_force_install
|
||||||
delegate_to: localhost
|
|
||||||
|
|
||||||
- name: cmk_apply (new)
|
- name: cmk_apply (new)
|
||||||
uri:
|
local_action:
|
||||||
|
module: uri
|
||||||
method: POST
|
method: POST
|
||||||
headers:
|
headers:
|
||||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||||
@@ -120,4 +122,3 @@
|
|||||||
when: >
|
when: >
|
||||||
cmk_add_host and cmk_major | int >= 2 and
|
cmk_add_host and cmk_major | int >= 2 and
|
||||||
cmk_minor | int >= 2 or cmk_force_install
|
cmk_minor | int >= 2 or cmk_force_install
|
||||||
delegate_to: localhost
|
|
||||||
|
|||||||
Reference in New Issue
Block a user