You've already forked ansible-role-checkmk-agent
fix: Revert changes to use local_action 🐛
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
---
|
||||
- name: Retrieve checkmk version
|
||||
local_action:
|
||||
module: uri
|
||||
uri:
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||
@@ -9,6 +8,7 @@
|
||||
url: '{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/api/1.0/version'
|
||||
return_content: true
|
||||
register: cmk_output
|
||||
|
||||
- name: Set facts # noqa jinja[spacing]
|
||||
set_fact:
|
||||
cmk_major: "{{ cmk_output.json.versions.checkmk | regex_search('(?P<major>\\\
|
||||
@@ -19,6 +19,7 @@
|
||||
d+)\\.(?P<minor>\\d+).(?P<patch>[\\d\\w]+).(?P<edition>\\w+)', '\\g<patch>') | first }}"
|
||||
cmk_edition: "{{ cmk_output.json.versions.checkmk | regex_search('(?P<major>\\\
|
||||
d+)\\.(?P<minor>\\d+).(?P<patch>[\\d\\w]+).(?P<edition>\\w+)','\\g<edition>') | first }}"
|
||||
|
||||
- name: Output vars
|
||||
debug:
|
||||
var: '{{ item }}'
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
- name: add host to omd (new)
|
||||
local_action:
|
||||
module: uri
|
||||
uri:
|
||||
method: POST
|
||||
headers:
|
||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||
@@ -19,6 +18,7 @@
|
||||
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,19 +28,19 @@
|
||||
when: cmk_add_host
|
||||
|
||||
- name: Host exists fetch etag (new) # noqa command-instead-of-module
|
||||
local_action:
|
||||
module: shell
|
||||
cmd: |
|
||||
curl \
|
||||
-G \
|
||||
-i \
|
||||
--request GET \
|
||||
--write-out "\nxxx-status_code=%{http_code}\n" \
|
||||
--header "Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}" \
|
||||
--header "Accept: application/json" \
|
||||
"{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/api/v0/objects/host_config/{{ inventory_hostname | upper }}"
|
||||
shell:
|
||||
cmd: |
|
||||
curl \
|
||||
-G \
|
||||
-i \
|
||||
--request GET \
|
||||
--write-out "\nxxx-status_code=%{http_code}\n" \
|
||||
--header "Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}" \
|
||||
--header "Accept: application/json" \
|
||||
"{{ 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
|
||||
@@ -55,8 +55,7 @@
|
||||
exists.$'))
|
||||
|
||||
- name: Update host as already exists? (new)
|
||||
local_action:
|
||||
module: uri
|
||||
uri:
|
||||
method: PUT
|
||||
headers:
|
||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||
@@ -72,6 +71,7 @@
|
||||
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
|
||||
@@ -83,8 +83,7 @@
|
||||
when: cmk_add_host
|
||||
|
||||
- name: cmk_discovery (new)
|
||||
local_action:
|
||||
module: uri
|
||||
uri:
|
||||
method: POST
|
||||
headers:
|
||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||
@@ -96,14 +95,14 @@
|
||||
body_format: json
|
||||
status_code: [200, 302]
|
||||
become: false
|
||||
delegate_to: localhost
|
||||
when: >
|
||||
cmk_add_host and cmk_major | int >= 2 and
|
||||
cmk_minor | int >= 2 or
|
||||
cmk_force_install
|
||||
|
||||
- name: cmk_apply (new)
|
||||
local_action:
|
||||
module: uri
|
||||
uri:
|
||||
method: POST
|
||||
headers:
|
||||
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
|
||||
|
||||
Reference in New Issue
Block a user