Files
windows-ansible/ansible/playbooks/checkmk.yml
T

154 lines
5.9 KiB
YAML

---
- 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"
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"
tags:
- checkmk_host
- 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"
when: project_zone == 'protected'
tags: checkmk_proxy
- name: Create downtimes for new VMs
block:
- name: "Schedule downtime on Windows VMs to cover deployment"
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
delegate_to: "localhost"
- name: "Schedule downtime on Proxy"
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: "{{ os_project }}-{{ win_project }}-proxy"
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
delegate_to: "localhost"
tags: checkmk_downtime
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"
run_once: true
- 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
#when: project_zone == 'standard' or
# inventory_hostname in groups['meta-type_server']
#- name: register TLS on client (Protected)
# vars:
# ansible_connection: local
# shell: |
# sudo cmk-agent-ctl proxy-register --hostname {{ inventory_hostname }} --server {{ checkmk_server }} --site {{ checkmk_agent_site }} --user {{ checkmk_agent_user }} --password '{{ checkmk_password }}' --trust-cert
# delegate_to: localhost
# when: project_zone == 'protected' and
# inventory_hostname in groups['meta-type_client']
tags:
- checkmk_host
- checkmk_tls
- checkmk_all