Files
ansible-role-checkmk-agent/tasks/host-configure/modern.yml
Aaron Guise 8cded0fb55
Some checks failed
CI / lint (push) Failing after 1m48s
CI / Molecule Test (almalinux8) (push) Has been skipped
CI / Molecule Test (almalinux9) (push) Has been skipped
CI / release (push) Has been skipped
CI / notify (push) Has been skipped
fix: Also now using local_action for host config in checkmk 🐛
2025-02-21 07:18:54 +13:00

58 lines
1.4 KiB
YAML

---
- name: Output contains
debug:
var: output
- name: cmk_discovery
local_action:
module: uri
method: POST
url: "{{ cmk_api_url }}/domain-types/service_discovery_run/actions/start/invoke"
headers:
Authorization: "Bearer {{ cmk_username }} {{ cmk_secret }}"
Accept: application/json
Content-Type: application/json
body_format: raw
body: |
{
"host_name": "{{ inventory_hostname | upper }}",
"mode": "fix_all"
}
status_code: 200
validate_certs: false
follow_redirects: true
become: false
when: cmk_add_host and res_add.status != 400 and output.id != ""
tags: cmk_register
- name: Just Waiting
pause:
seconds: 20
- name: cmk_apply
local_action:
module: uri
method: POST
url: '{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/api/1.0/domain-types/activation_run/actions/activate-changes/invoke'
headers:
Authorization: Bearer {{ cmk_username }} {{ cmk_secret }}
Accept: application/json
If-Match: "*"
body_format: json
body:
redirect: false
sites:
- "{{ cmk_omd_site }}"
force_foreign_changes: false
status_code: [200]
validate_certs: false
follow_redirects: true
become: false
run_once: true
when: cmk_add_host and res_add.status != 400 and output.id != ""
tags: cmk_register
- name: Wait some time
pause:
seconds: 10