separate add host and discover. stop error

This commit is contained in:
2021-10-05 13:55:06 +13:00
parent 59d43f8112
commit 2ae40a30a9
2 changed files with 31 additions and 0 deletions

29
tasks/host-configure.yml Normal file
View File

@@ -0,0 +1,29 @@
---
- 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: no
follow_redirects: yes
become: no
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: no
follow_redirects: yes
become: no
run_once: true
when: "cmk_add_host and output.result_code == 0"
delegate_to: localhost
tags: cmk_register

View File

@@ -7,3 +7,5 @@
when: cmk_fresh_install
- include_tasks: "{{ ansible_os_family }}-register.yml"
when: cmk_fresh_install
- include_tasks: host-configure.yml
when: cmk_fresh_install