--- - name: CheckMK Hosts hosts: "meta-win_project_{{ win_project }}:&meta-os_windows" gather_facts: false vars_files: - ../vars/checkmk.yml - ../vars/common.yml tasks: - name: "Create folder for eidf project" checkmk.general.folder: server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_server }}:80/" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" automation_secret: "{{ checkmk_password }}" path: "/{{ os_project }}-{{ win_project }}" name: "{{ os_project }}-{{ win_project }}" state: "{{ state }}" # might need to create hosts them move so teardown works??? or leave folder after teardown or add only teardown task after run_once: true delegate_to: "localhost" notify: "activate changes" tags: - checkmk_folder - checkmk_host - checkmk_all - teardown - name: Add Windows 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: "/{{ os_project }}-{{ win_project }}" name: "{{ inventory_hostname }}" attributes: ipaddress: "{{ hostvars[inventory_hostname].ansible_host }}" tag_Variant: "{{ hostvars[inventory_hostname].openstack.metadata.variant }}" tag_project_zone: "{{ project_zone }}" state: "{{ state }}" delegate_to: "localhost" notify: - "activate changes" - "schedule downtime" tags: - checkmk_host - checkmk_host_update - checkmk_all - name: Move Proxy to project specific checkmk folder 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: "{{ os_project }}-{{ win_project }}-proxy" state: "present" run_once: true delegate_to: "localhost" notify: - "activate changes" - "schedule downtime" when: project_zone == 'protected' tags: - checkmk_proxy - checkmk_all - name: Pause for 30 seconds ansible.builtin.pause: seconds: 30 run_once: true - name: Flush handlers meta: flush_handlers tags: always handlers: - name: "Activate Changes" listen: activate changes checkmk.general.activation: server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_server }}:80/" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" automation_secret: "{{ checkmk_password }}" force_foreign_changes: "false" validate_certs: "true" delegate_to: "localhost" tags: always run_once: true - name: "Schedule downtime" listen: schedule downtime checkmk.general.downtime: server_url: "{{ checkmk_agent_protocol }}://{{ checkmk_server }}:80/" site: "{{ checkmk_agent_site }}" automation_user: "{{ checkmk_agent_user }}" automation_secret: "{{ checkmk_password }}" host_name: "{{ inventory_hostname }}" state: "{{ state }}" # might need to create hosts them move so teardown works??? or leave folder after teardown or add only teardown task after start_after: minutes: 0 end_after: days: 0 hours: 3 tags: always delegate_to: "localhost" - name: CheckMK Agent hosts: "meta-win_project_{{ win_project }}:&meta-os_windows" gather_facts: false collections: - checkmk.general vars_files: - ../vars/checkmk.yml - ../vars/common.yml - ../vars/connection.yml tasks: - name: Install CheckMK agent on VMs block: - name: Gather Facts setup: tags: - checkmk_all - checkmk_agent - name: Install CheckMK agent on VMs import_role: name: agent tags: - checkmk_all - checkmk_agent - name: TLS registrtion block: - name: register for TLS win_shell: | sl 'C:\Program Files (x86)\checkmk\service' .\cmk-agent-ctl register --hostname {{ inventory_hostname }} --server {{ checkmk_server }} --site {{ checkmk_agent_site }} --user {{ checkmk_agent_user }} --password '{{ checkmk_password }}' --trust-cert tags: - checkmk_host - checkmk_tls - checkmk_all