Browse Source

Refactoring: Add FreeBSD support

master
squeaky otter 1 year ago
parent
commit
1533dba484
Signed by: dashie GPG Key ID: C2D57B325840B755
  1. 44
      tasks/freebsd-install.yml
  2. 45
      tasks/install-agent.yml
  3. 2
      tasks/setup-Debian.yml
  4. 11
      tasks/setup-FreeBSD.yml
  5. 1
      tasks/setup-RedHat.yml
  6. 26
      tasks/systemd-install.yml
  7. 1
      vars/Debian.yml
  8. 1
      vars/FreeBSD.yml

44
tasks/freebsd-install.yml

@ -0,0 +1,44 @@
- name: Copy check_mk_agent
copy:
src: "/opt/librenms-agent/check_mk_agent_freebsd"
dest: "{{ prefix }}/bin/check_mk_agent"
mode: "0755"
remote_src: true
- name: Create xinetd directory
file:
path: "{{prefix}}/etc/xinet.d/"
state: directory
- name: Deploy xinetd config
copy:
src: "/opt/librenms-agent/check_mk_xinetd"
dest: "{{ prefix }}/etc/xinet.d/check_mk"
remote_src: true
- name: Copy mk_enplug
copy:
src: "/opt/librenms-agent/mk_enplug"
dest: "{{ prefix }}/bin"
remote_src: true
- name: Copy distro
copy:
src: "/opt/librenms-agent/snmp/distro"
dest: "{{ prefix }}/bin"
remote_src: true
- name: Configure check_mk xinetd
replace:
path: "{{ prefix }}/etc/xinet.d/check_mk"
regexp: '\/usr\/bin\/check_mk_agent$'
replace: '/usr/local/bin/check_mk_agent'
- name: Enable xinetd
shell: service xinetd enable
- name: Start xinetd
service:
name: xinetd
state: "started"
enabled: True

45
tasks/install-agent.yml

@ -5,55 +5,37 @@
version: '{{ librenms_agent_version }}'
force: yes
- name: Copy check_mk_agent
copy:
src: /opt/librenms-agent/check_mk_agent
dest: /usr/bin/check_mk_agent
mode: 0755
remote_src: true
- name: Install systemd service
copy:
src: /opt/librenms-agent/check_mk@.service
dest: /etc/systemd/system/check_mk@.service
remote_src: true
when: ansible_service_mgr == 'systemd'
- name: Install systemd service socket
copy:
src: /opt/librenms-agent/check_mk.socket
dest: /etc/systemd/system/check_mk.socket
remote_src: true
when: ansible_service_mgr == 'systemd'
- name: "get {{ ansible_os_family }} variables"
include_vars: "{{ ansible_os_family }}.yml"
- name: Create agent directories
file:
path: '{{ item }}'
state: directory
with_items:
- /usr/lib/check_mk_agent/plugins
- /usr/lib/check_mk_agent/local
- "{{ prefix }}/lib/check_mk_agent/plugins"
- "{{ prefix }}/lib/check_mk_agent/local"
- name: Install check_mk agent scripts
copy:
src: '/opt/librenms-agent/agent-local/{{ item }}'
dest: '/usr/lib/check_mk_agent/local/{{ item }}'
mode: 0755
dest: "{{prefix}}/lib/check_mk_agent/local/{{ item }}"
mode: "0755"
remote_src: true
with_flattened: '{{ librenms_agent_check_mk_scripts }}'
- name: Enable check_mk service socket
systemd:
name: check_mk.socket
state: restarted
enabled: yes
daemon_reload: yes
- name: systemd-like post-install
include_tasks: systemd-install.yml
when: ansible_service_mgr == 'systemd'
- name: freebsd post-install
include_tasks: freebsd-install.yml
when: ansible_os_family == 'FreeBSD'
- name: Fix some scripts execution bit
file:
path: '/opt/librenms-agent/snmp/{{ item }}'
mode: 0755
mode: "0755"
with_items:
- zfs-linux
- unbound
@ -73,5 +55,4 @@
- powerdns-dnsdist
- sdfsinfo
- smart
- squid

2
tasks/setup-Debian.yml

@ -4,11 +4,9 @@
apt:
name: "apt-transport-https"
state: present
when: ansible_os_family == 'Debian'
- name: Ensure git is installed
apt:
name: "git"
state: present
when: ansible_os_family == 'Debian'

11
tasks/setup-FreeBSD.yml

@ -0,0 +1,11 @@
---
- name: Ensure required packages are installed
pkgng:
name:
- git
- bash
- xinetd
- libstatgrab
state: present

1
tasks/setup-RedHat.yml

@ -4,4 +4,3 @@
yum:
name: "epel-release"
state: present
when: ansible_distribution == 'RedHat'

26
tasks/systemd-install.yml

@ -0,0 +1,26 @@
---
- name: Copy check_mk_agent
copy:
src: /opt/librenms-agent/check_mk_agent
dest: "{{ prefix }}/bin/check_mk_agent"
mode: "0755"
remote_src: true
- name: Install systemd service
copy:
src: /opt/librenms-agent/check_mk@.service
dest: /etc/systemd/system/check_mk@.service
remote_src: true
- name: Install systemd service socket
copy:
src: /opt/librenms-agent/check_mk.socket
dest: /etc/systemd/system/check_mk.socket
remote_src: true
- name: Enable check_mk service socket
systemd:
name: check_mk.socket
state: restarted
enabled: yes
daemon_reload: yes

1
vars/Debian.yml

@ -0,0 +1 @@
prefix: '/usr'

1
vars/FreeBSD.yml

@ -0,0 +1 @@
prefix: '/usr/local'
Loading…
Cancel
Save