Created
August 17, 2022 08:09
-
-
Save robin-checkmk/619bcb13831a77b6e1170c8c17bd17af to your computer and use it in GitHub Desktop.
yt.yml from the Checkmk Ansible collection introduction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "Roles." | |
hosts: localhost | |
gather_facts: true | |
vars_files: | |
- ./vars/config.yml | |
tasks: | |
- name: "Run server role." | |
ansible.builtin.import_role: | |
name: tribe29.checkmk.server | |
- name: "Run agent role." | |
ansible.builtin.import_role: | |
name: tribe29.checkmk.agent | |
- name: "Pause." | |
ansible.builtin.pause: | |
prompt: | | |
"Press <Enter> to continue." | |
- name: "Modules." | |
hosts: test | |
gather_facts: false | |
vars_files: | |
- ./vars/config.yml | |
tasks: | |
- name: "Activate changes on site - Showcase no changes." | |
tribe29.checkmk.activation: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
force_foreign_changes: true | |
sites: | |
- "{{ site }}" | |
delegate_to: localhost | |
run_once: true | |
- name: "Create folders." | |
tribe29.checkmk.folder: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
path: "{{ item.path }}" | |
title: "{{ item.title }}" | |
state: "present" | |
delegate_to: localhost | |
run_once: true | |
loop: "{{ checkmk_folders }}" | |
- name: "Create host." | |
tribe29.checkmk.host: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
host_name: "{{ inventory_hostname }}" | |
folder: "{{ checkmk_folder_path }}" | |
attributes: | |
site: "{{ site }}" | |
ipaddress: 127.0.0.1 | |
state: "present" | |
delegate_to: localhost | |
- name: "Discover services on host." | |
tribe29.checkmk.discovery: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
host_name: "{{ inventory_hostname }}" | |
state: "fix_all" | |
delegate_to: localhost | |
- name: "Activate changes on site - Showcase creation of hosts and folders." | |
tribe29.checkmk.activation: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
force_foreign_changes: true | |
sites: | |
- "{{ site }}" | |
delegate_to: localhost | |
run_once: true | |
- name: "Pause." | |
ansible.builtin.pause: | |
prompt: | | |
"Press <Enter> to continue." | |
- name: "Delete Host." | |
tribe29.checkmk.host: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
host_name: "{{ inventory_hostname }}" | |
folder: "{{ checkmk_folder_path }}" | |
state: "absent" | |
delegate_to: localhost | |
when: not inventory_hostname == "localhost" | |
- name: "Delete folders." | |
tribe29.checkmk.folder: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
path: "{{ item.path }}" | |
title: "{{ item.title }}" | |
state: "absent" | |
register: testout | |
delegate_to: localhost | |
run_once: true | |
loop: "{{ checkmk_folders }}" | |
- name: "Activate changes on site - Showcase host and folders were deleted" | |
tribe29.checkmk.activation: | |
server_url: "{{ server_url }}" | |
site: "{{ site }}" | |
automation_user: "{{ automation_user }}" | |
automation_secret: "{{ automation_secret }}" | |
force_foreign_changes: true | |
sites: | |
- "{{ site }}" | |
delegate_to: localhost | |
run_once: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And here is the inventory file you need to create:
hosts
And the vars file:
./vars/config.yml