Files
role-check-mk-agent/tasks/RedHat.yml
2021-10-19 16:31:38 +13:00

78 lines
2.2 KiB
YAML

---
# 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
- name: Install check-mk-agent
block:
- name: Check if check-mk-agent is present on server
stat:
path: /tmp/check-mk-agent.rpm
register: cmkrpm
- name: Download the agent from Server
get_url:
url: "{{ cmk_rpm_agent }}{{ cmk_auth }}"
dest: /tmp/check-mk-agent.rpm
validate_certs: false
when: not cmkrpm.stat.exists and cmk_dl_needs_auth|bool
- name: Download the agent from Server
get_url:
url: "{{ cmk_rpm_agent }}"
dest: /tmp/check-mk-agent.rpm
validate_certs: false
when: not cmkrpm.stat.exists and not cmk_dl_needs_auth|bool
- name: Ensure check_mk_agent installed
command: /usr/bin/yum install --nogpgcheck -y /tmp/check-mk-agent.rpm
args:
warn: no
notify:
- restart xinetd
- cmk fresh install
- ensure firewall open
when: "'check-mk-agent' not in ansible_facts.packages or cmk_force_install"
tags:
- check_mk_agent