Debian support

This commit is contained in:
2022-08-09 07:40:13 +12:00
parent c449ae2435
commit 602656dde5
3 changed files with 150 additions and 1 deletions

View File

@@ -10,13 +10,22 @@
set_fact:
cmk_fresh_install: True
- name: ensure firewall open
- name: ensure firewall open (rhel)
firewalld:
port: 6556/tcp
state: enabled
permanent: yes
immediate: yes
ignore_errors: true
when: ansible_os_family == "RedHat"
- name: ensure firewall open (debian)
ufw:
rule: allow
port: 6556
proto: tcp
ignore_errors: true
when: ansible_os_family == "Debian"
- name: remove agent
file:

53
tasks/Debian-register.yml Normal file
View File

@@ -0,0 +1,53 @@
- block:
- name: Register with CheckMK Update Server
shell: |
cmk-update-agent register -H {{ instance_name | default(inventory_hostname) }} \
--user {{ cmk_username }} \
--secret {{ cmk_secret }}
changed_when: false
notify: remove agent
tags: cmk_register
- name: Check-In with server
shell: |
cmk-update-agent -v
changed_when: false
notify: remove agent
tags: cmk_register
rescue:
- name: Gather facts of packages
package_facts:
manager: "auto"
tags: cmk_register
- name: Ensure check_mk_agent installed (again)
package:
deb: /tmp/check-mk-agent.deb
state: present
allow_unauthenticated: true
notify:
- restart xinetd
- ensure firewall open
when: "'check-mk-agent' not in ansible_facts.packages"
tags: cmk_register
- name: Gather facts of packages (again)
package_facts:
manager: "auto"
tags: cmk_register
- name: Register with CheckMK Update Server (retry)
shell: |
cmk-update-agent register -H {{ instance_name | default(inventory_hostname) }} --user {{ cmk_username }} \
--secret {{ cmk_secret }}
changed_when: false
when: "'check-mk-agent' in ansible_facts.packages"
notify: remove agent
tags: cmk_register
- name: Check-In with server
shell: |
cmk-update-agent -v
changed_when: false
notify: remove agent
tags: cmk_register

87
tasks/Debian.yml Normal file
View File

@@ -0,0 +1,87 @@
---
# Tasks for installation on RedHat Family
- name: Ensure xinetd installed
package:
name: xinetd
state: present
notify: restart xinetd
- name: Fix SeLinux Auto-Updates
block:
- name: list installed selinux modules
command: /usr/sbin/semodule -l
register: installed_mods
- name: check_mk_mod_installed
set_fact:
cmk_mod_installed: True
when: '"checkmk-agent-autoupgrade" in installed_mods.stdout'
- name: copy file
copy:
src: files/checkmk-agent-autoupgrade.pp
dest: /tmp/checkmk-agent-autoupgrade.pp
when: cmk_mod_installed is not defined
- name: install the module
command: /usr/sbin/semodule -i /tmp/checkmk-agent-autoupgrade.pp
when: cmk_mod_installed is not defined
notify: remove selinux policy file
when: ansible_selinux|bool
tags: selinux-pre
- name: Gather facts of packages
package_facts:
manager: "auto"
- name: Remove check-mk if force install
package:
name: check-mk-agent
state: absent
when: "cmk_force_install and 'check-mk-agent' in ansible_facts.packages"
- name: Re-check check-mk-agent status
package_facts:
manager: "auto"
when: cmk_force_install
# Download agent by samba share
- include_tasks: downloads/samba/main.yml
when: cmk_download_mode == 'samba'
- name: Copy installer to node
copy:
src: /tmp/dls/{{ cmk_installer }}
dest: /tmp/check-mk-agent.deb
- name: Install check-mk-agent
block:
- name: Check if check-mk-agent is present on server
stat:
path: /tmp/check-mk-agent.deb
register: cmkdeb
- name: Download the agent from Server
get_url:
url: "{{ cmk_deb_agent }}{{ cmk_auth }}"
dest: /tmp/check-mk-agent.deb
validate_certs: false
when: not cmkdeb.stat.exists and cmk_dl_needs_auth|bool
- name: Download the agent from Server
get_url:
url: "{{ cmk_deb_agent }}"
dest: /tmp/check-mk-agent.deb
validate_certs: false
when: not cmkdeb.stat.exists and not cmk_dl_needs_auth|bool
- name: Ensure check_mk_agent installed
package:
deb: /tmp/check-mk-agent.deb
state: present
allow_unauthenticated: true # Not gpg signed so bypass the check
notify:
- restart xinetd
- cmk fresh install
- ensure firewall open (debian)
when: "'check-mk-agent' not in ansible_facts.packages or cmk_force_install"
tags:
- check_mk_agent