Эх сурвалжийг харах

Merge pull request #1061 from ChristianLempa:ansible-checkmk-updates

ansible checkmk collection templates
Christian Lempa 9 сар өмнө
parent
commit
d9908f4447

+ 19 - 0
ansible/checkmk/activate-changes.yaml

@@ -0,0 +1,19 @@
+---
+- name: "Activate Checkmk changes"
+  hosts: localhost
+  gather_facts: false
+  vars_files:
+    - secrets.yaml
+  vars:
+    server_url: "checkmk.home.arpa"
+    site: "cmk"
+
+  tasks:
+    - name: "Start activation on a specific site"
+      checkmk.general.activation:
+        server_url: "{{ server_url }}"
+        site: "{{ site }}"
+        automation_user: "{{ automation_user }}"
+        automation_secret: "{{ automation_secret }}"
+        sites:
+          - "{{ site }}"

+ 17 - 0
ansible/checkmk/install-agent.yaml

@@ -0,0 +1,17 @@
+---
+- name: "Install Checkmk agent on all hosts"
+  hosts: "{{ my_hosts | d([]) }}"
+  roles:
+    - checkmk.general.agent
+  vars:
+    checkmk_agent_version: "2.4.0p4"
+    checkmk_agent_server: "checkmk.home.arpa"
+    checkmk_agent_server_protocol: https
+    checkmk_agent_site: "cmk"
+    checkmk_agent_auto_activate: true
+    checkmk_agent_tls: "true"  # NOTE: Register Agent to enable TLS
+    checkmk_agent_user: "{{ automation_user }}"
+    checkmk_agent_pass: "{{ automation_secret }}"
+    checkmk_agent_host_name: "{{ ansible_hostname }}"  # NOTE: Required to replace FQDN with hostname only
+  vars_files:
+    - secrets.yaml

+ 25 - 0
ansible/checkmk/lookup-rule.yaml

@@ -0,0 +1,25 @@
+---
+- name: "Manage Checkmk rules"
+  hosts: localhost
+  gather_facts: false
+  vars_files:
+    - secrets.yaml
+  vars:
+    server_url: "checkmk.home.arpa"
+    site: "cmk"
+
+  tasks:
+    - name: Get a rule with a particular rule id
+      ansible.builtin.debug:
+        msg: "Rule: {{ extensions | to_nice_yaml }}"
+      vars:
+        extensions: "{{
+          lookup('checkmk.general.rule',
+            rule_id='checkmk-rule-id',
+            server_url=server_url,
+            site=site,
+            automation_user=automation_user,
+            automation_secret=automation_secret,
+            validate_certs=False
+            )
+          }}"

+ 22 - 0
ansible/checkmk/manage-hosts.yaml

@@ -0,0 +1,22 @@
+---
+- name: "Manage Checkmk hosts"
+  hosts: localhost
+  gather_facts: false
+  vars_files:
+    - secrets.yaml
+  vars:
+    server_url: "checkmk.home.arpa"
+    site: "cmk"
+
+  tasks:
+    - name: "Create host"
+      checkmk.general.host:
+        server_url: "{{ server_url }}"
+        site: "{{ site }}"
+        automation_user: "{{ automation_user }}"
+        automation_secret: "{{ automation_secret }}"
+        name: "your-host-name"
+        attributes:
+          ipaddress: "host-ip-address"
+        folder: "/"
+        state: "present"

+ 71 - 0
ansible/checkmk/manage-rules.yaml

@@ -0,0 +1,71 @@
+---
+- name: "Manage Checkmk rules"
+  hosts: localhost
+  gather_facts: false
+  vars_files:
+    - secrets.yaml
+  vars:
+    server_url: "checkmk.home.arpa"
+    site: "cmk"
+
+  tasks:
+    - name: Create DNS Check Rule
+      checkmk.general.rule:
+        server_url: "{{ server_url }}"
+        site: "{{ site }}"
+        automation_user: "{{ automation_user }}"
+        automation_secret: "{{ automation_secret }}"
+        ruleset: "active_checks:dns"
+        rule:
+          properties: {
+            "comment": "Ansible managed",
+            "description": "DNS DNS Monitoring",
+            "disabled": false,
+          }
+          conditions: {
+            "host_label_groups": [],
+            "host_name": {
+              "match_on": [
+                "your-dns-container-host"
+              ],
+              "operator": "one_of"
+            },
+            "host_tags": [],
+            "service_label_groups": []
+          }
+          "value_raw": {
+            "hostname": "hostname-to-query",
+            "server": "dns-server-ip",
+            "expected_addresses_list": [
+              "expected-ip-address"
+            ]
+          }
+          location:
+            folder: "/"
+            position: "top"
+        state: "present"
+
+    - name: Create NVME Temperature override rule
+      checkmk.general.rule:
+        server_url: "{{ server_url }}"
+        site: "{{ site }}"
+        automation_user: "{{ automation_user }}"
+        automation_secret: "{{ automation_secret }}"
+        ruleset: "checkgroup_parameters:temperature"
+        rule:
+          conditions:
+            host_label_groups: []
+            host_tags: []
+            service_description:
+              match_on:
+                - "DRIVE MODEL NAME*"
+              operator: "one_of"
+            service_label_groups: []
+          location:
+            folder: "/"
+            position: "top"
+          properties:
+            description: "NVME Temperature override"
+            disabled: false
+          value_raw: "{'levels': (60.0, 80.0)}"
+        state: present

+ 3 - 0
ansible/checkmk/secrets.yaml

@@ -0,0 +1,3 @@
+---
+automation_user: "your-checkmk-user"
+automation_secret: "your-checkmk-password"