From 2ae40a30a9e097615901b29cd600feb14879b8d3 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Tue, 5 Oct 2021 13:55:06 +1300 Subject: [PATCH] separate add host and discover. stop error --- tasks/host-configure.yml | 29 +++++++++++++++++++++++++++++ tasks/main.yml | 2 ++ 2 files changed, 31 insertions(+) create mode 100644 tasks/host-configure.yml diff --git a/tasks/host-configure.yml b/tasks/host-configure.yml new file mode 100644 index 0000000..72cabff --- /dev/null +++ b/tasks/host-configure.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 4d822ca..6e36357 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,4 +6,6 @@ - include_tasks: host-management.yml when: cmk_fresh_install - include_tasks: "{{ ansible_os_family }}-register.yml" + when: cmk_fresh_install +- include_tasks: host-configure.yml when: cmk_fresh_install \ No newline at end of file