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