Files
ansible-role-checkmk-agent/tasks/host-configure.yml
2024-01-09 14:33:55 +13:00

63 lines
1.9 KiB
YAML

---
- name: cmk_discovery
uri:
method: POST
url: '{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=discover_services&mode=refresh{{
cmk_auth }}'
body: request={"hostname":"{{ instance_name | default(inventory_hostname) }}"}
body_format: raw
status_code: 200
validate_certs: false
follow_redirects: true
become: false
when: cmk_add_host and output.result_code == 0
delegate_to: localhost
tags: cmk_register
- name: cmk_apply
uri:
method: POST
url: '{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=activate_changes&mode=specific{{
cmk_auth }}'
body: request={"sites":["{{ cmk_omd_site }}"]}
body_format: raw
status_code: 200
validate_certs: false
follow_redirects: true
become: false
run_once: true
when: cmk_add_host and output.result_code == 0
delegate_to: localhost
tags: cmk_register
- name: Wait some time
pause:
seconds: 10
- name: cmk_discovery x 2
uri:
method: POST
url: '{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=discover_services&mode=refresh{{
cmk_auth }}'
body: request={"hostname":"{{ instance_name | default(inventory_hostname) }}"}
body_format: raw
status_code: 200
validate_certs: false
follow_redirects: true
become: false
when: cmk_add_host and output.result_code == 0
delegate_to: localhost
tags: cmk_register
- name: cmk_apply
uri:
method: POST
url: '{{ cmk_omd_protocol }}://{{ cmk_omd_host }}/{{ cmk_omd_site }}/check_mk/webapi.py?action=activate_changes&mode=specific{{
cmk_auth }}'
body: request={"sites":["{{ cmk_omd_site }}"]}
body_format: raw
status_code: 200
validate_certs: false
follow_redirects: true
become: false
run_once: true
when: cmk_add_host and output.result_code == 0
delegate_to: localhost
tags: cmk_register