-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathrules.yml
131 lines (121 loc) · 4.58 KB
/
rules.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
- name: "Showcase rule module."
hosts: test
strategy: linear
gather_facts: false
vars_files:
- ../vars/auth.yml # This vars file provides details about your site
- ../vars/folders.yml # This vars file contains the folders to manage
- ../vars/rules.yml # This vars file contains the groups to manage
tasks:
- name: "Gather Date and Time Facts on localhost."
ansible.builtin.setup:
gather_subset:
- date_time
delegate_to: localhost
run_once: true # noqa run-once[task]
- name: "Create folders."
folder:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
path: "{{ item.path }}"
name: "{{ item.name }}"
state: "present"
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_var_folders }}"
- name: "Create hosts."
host:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ inventory_hostname }}"
folder: "{{ checkmk_var_folder_path }}"
attributes:
site: "{{ checkmk_var_site }}"
ipaddress: 127.0.0.1
state: "present"
delegate_to: localhost
- name: "Create rules."
rule:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
ruleset: "{{ item.ruleset }}"
rule: "{{ item.rule }}"
state: "present"
loop: "{{ checkmk_var_rules }}"
run_once: true # noqa run-once[task]
delegate_to: localhost
- name: "Pause to review changes."
ansible.builtin.pause:
prompt: |
"Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}."
"Press <Enter> to continue."
when: not checkmk_var_run_unattended | bool
- name: "Activate changes on site."
activation:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
force_foreign_changes: 'true'
sites:
- "{{ checkmk_var_site }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
- name: "Delete rules."
rule:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
ruleset: "{{ item.ruleset }}"
rule: "{{ item.rule }}"
state: "absent"
loop: "{{ checkmk_var_rules }}"
run_once: true # noqa run-once[task]
delegate_to: localhost
- name: "Delete Hosts."
host:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ inventory_hostname }}"
folder: "{{ checkmk_var_folder_path }}"
state: "absent"
delegate_to: localhost
- name: "Delete folders."
folder:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
path: "{{ item.path }}"
name: "{{ item.name }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_var_folders }}"
- name: "Pause to review changes."
ansible.builtin.pause:
prompt: |
"Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}."
"Press <Enter> to continue."
when: not checkmk_var_run_unattended | bool
- name: "Activate changes on site."
activation:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
force_foreign_changes: 'true'
sites:
- "{{ checkmk_var_site }}"
delegate_to: localhost
run_once: true # noqa run-once[task]