add host to project folder when failing resort to root folder

This commit is contained in:
abrown38 committed 2024-12-11 14:47:25 +00:00
1 parent 1c4b349434
commit b82db1424e
1 file changed
+28 -15
+28 -15
View File
@@ -11,20 +11,34 @@
file: ../vars/checkmk.yml
- name: Add proxy host into checkMK
checkmk.general.host:
server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_server }}:80/"
site: "{{ checkmk_agent_site }}"
validate_certs: "true"
automation_user: "{{ checkmk_agent_user }}"
automation_secret: "{{ checkmk_password }}"
folder: "/"
name: "{{ inventory_hostname }}"
attributes:
ipaddress: "{{ hostvars[inventory_hostname].ansible_host }}"
tag_Variant: "proxy"
tag_project_zone: "{{ project_zone }}"
state: "present"
notify: "activate changes"
block:
- name: Add {{ inventory_hostname }} to "/{{ os_project }}-{{ win_project }}" CheckMK
checkmk.general.host:
server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_server }}:80/"
site: "{{ checkmk_agent_site }}"
validate_certs: "true"
automation_user: "{{ checkmk_agent_user }}"
automation_secret: "{{ checkmk_password }}"
folder: "/{{ os_project }}-{{ win_project }}"
name: "{{ inventory_hostname }}"
attributes:
ipaddress: "{{ hostvars[inventory_hostname].ansible_host }}"
state: "present"
notify: "activate changes"
rescue:
- name: Add {{ inventory_hostname }} to "/" CheckMK
checkmk.general.host:
server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_server }}:80/"
site: "{{ checkmk_agent_site }}"
validate_certs: "true"
automation_user: "{{ checkmk_agent_user }}"
automation_secret: "{{ checkmk_password }}"
folder: "/"
name: "{{ inventory_hostname }}"
attributes:
ipaddress: "{{ hostvars[inventory_hostname].ansible_host }}"
state: "present"
notify: "activate changes"
- name: Install CheckMK Agent
import_role:
@@ -34,4 +48,3 @@
- name: register agent for TLS
shell: |
cmk-agent-ctl register --hostname {{ inventory_hostname }} --server {{ checkmk_server }} --site {{ checkmk_agent_site }} --user {{ checkmk_agent_user }} --password '{{ checkmk_password }}' --trust-cert