2016-08-08 19:42:36 +00:00
|
|
|
# collectd client setup
|
2013-06-07 19:36:29 +00:00
|
|
|
|
|
|
|
# install pkg
|
2024-11-27 13:48:08 +10:00
|
|
|
---
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd
|
2024-12-19 13:22:42 +10:00
|
|
|
ansible.builtin.package: name=collectd state=present
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int <= 7 and ansible_distribution == 'RedHat'
|
2015-11-09 17:49:49 +00:00
|
|
|
|
|
|
|
# install pkg
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd
|
2015-11-09 17:49:49 +00:00
|
|
|
dnf: name=collectd state=present
|
|
|
|
tags:
|
|
|
|
- collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int > 7 and ansible_distribution == 'RedHat'
|
2019-09-02 12:14:18 +02:00
|
|
|
|
|
|
|
# install pkg
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd
|
2019-09-02 12:14:18 +02:00
|
|
|
dnf: name=collectd state=present
|
|
|
|
tags:
|
|
|
|
- collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int >= 29 and ansible_distribution == 'Fedora'
|
2019-09-02 12:14:18 +02:00
|
|
|
|
|
|
|
# install collectd-disk (it was split out)
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd-disk
|
2019-09-02 12:14:18 +02:00
|
|
|
dnf: name=collectd-disk state=present
|
|
|
|
tags:
|
|
|
|
- collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int > 7 and ansible_distribution == 'RedHat'
|
2013-06-07 19:36:29 +00:00
|
|
|
|
2016-11-28 19:05:14 -08:00
|
|
|
# install collectd-disk on F25+ (it was split out)
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd-disk
|
2016-11-28 19:05:14 -08:00
|
|
|
dnf: name=collectd-disk state=present
|
|
|
|
tags:
|
|
|
|
- collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: ansible_distribution_major_version|int > 24 and ansible_distribution == 'Fedora'
|
2016-11-28 19:05:14 -08:00
|
|
|
|
2013-06-07 19:36:29 +00:00
|
|
|
# install collected.conf
|
|
|
|
- name: /etc/collectd.conf
|
2025-01-13 12:24:19 +10:00
|
|
|
ansible.builtin.template: src=collectd.conf.j2 dest=/etc/collectd.conf
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2013-06-07 19:36:29 +00:00
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2013-06-07 19:36:29 +00:00
|
|
|
|
|
|
|
# install collectd-network config
|
2013-06-07 19:55:34 +00:00
|
|
|
- name: /etc/collectd.d/network.conf
|
2025-01-13 12:24:19 +10:00
|
|
|
ansible.builtin.template: src=network-client.conf.j2 dest=/etc/collectd.d/network.conf
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2013-06-07 19:36:29 +00:00
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2014-07-16 21:01:29 +00:00
|
|
|
when: not inventory_hostname.startswith('log')
|
|
|
|
|
|
|
|
# install collectd-network config
|
|
|
|
- name: /etc/collectd.d/network.conf
|
2024-12-18 08:23:28 +10:00
|
|
|
ansible.builtin.copy: src=network-server.conf dest=/etc/collectd.d/network.conf
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-07-16 21:01:29 +00:00
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2014-07-16 21:01:29 +00:00
|
|
|
when: inventory_hostname.startswith('log')
|
2013-06-07 19:36:29 +00:00
|
|
|
|
|
|
|
# apache - localhost only - pretty much any apache server
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd-apache (yum)
|
2024-12-19 13:22:42 +10:00
|
|
|
ansible.builtin.package: state=present name=collectd-apache
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2013-06-07 19:36:29 +00:00
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: collectd_apache and ansible_distribution_major_version|int <= 7 and ansible_distribution == 'RedHat'
|
2019-09-02 12:14:18 +02:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd-apache (dnf)
|
2019-09-02 12:14:18 +02:00
|
|
|
dnf: state=present name=collectd-apache
|
|
|
|
tags:
|
|
|
|
- collectd
|
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: collectd_apache and ansible_distribution_major_version|int > 7 and ansible_distribution == 'RedHat'
|
2016-12-01 18:34:46 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install collectd-apache (dnf)
|
2016-12-01 18:34:46 +00:00
|
|
|
dnf: state=present name=collectd-apache
|
|
|
|
tags:
|
|
|
|
- collectd
|
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: collectd_apache and ansible_distribution_major_version|int >= 29 and ansible_distribution == 'Fedora'
|
2013-06-07 19:36:29 +00:00
|
|
|
|
|
|
|
- name: /etc/collectd/apache.conf
|
2024-12-18 08:23:28 +10:00
|
|
|
ansible.builtin.copy: src=apache.conf dest=/etc/collectd.d/apache.conf
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2013-06-07 19:36:29 +00:00
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2016-12-01 04:01:10 +00:00
|
|
|
when: collectd_apache
|
2013-06-07 19:36:29 +00:00
|
|
|
|
2015-05-28 18:09:03 +00:00
|
|
|
- name: Install libsemanage-python so we can set an sebool below
|
2024-12-19 13:22:42 +10:00
|
|
|
ansible.builtin.package: name=libsemanage-python state=present
|
2015-05-28 18:09:03 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2019-09-19 19:27:25 +00:00
|
|
|
when: collectd_apache is defined and ansible_distribution_major_version|int <= 7 and ansible_distribution == 'RedHat'
|
2015-05-28 18:09:03 +00:00
|
|
|
|
2015-06-14 00:16:39 +00:00
|
|
|
- name: Let collectd talk to things over tcp
|
2015-05-25 19:28:08 +00:00
|
|
|
seboolean: name=collectd_tcp_network_connect state=yes persistent=yes
|
|
|
|
tags:
|
|
|
|
- collectd
|
2024-11-27 13:48:08 +10:00
|
|
|
ignore_errors: true
|
2015-05-25 19:28:08 +00:00
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2018-03-05 17:59:38 +00:00
|
|
|
when: ( collectd_apache is defined ) and ansible_selinux.status != "disabled"
|
2014-07-18 19:38:00 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Enable collectd nfs module
|
2024-12-18 08:23:28 +10:00
|
|
|
ansible.builtin.copy: src=nfs.conf dest=/etc/collectd.d/nfs.conf
|
2015-06-10 22:15:52 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
|
|
|
notify:
|
2025-02-07 13:51:07 +01:00
|
|
|
- Restart collectd
|
2015-06-10 22:15:52 +00:00
|
|
|
|
2014-11-05 16:04:43 +00:00
|
|
|
# Three tasks for handling our (two) custom selinux modules.
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Ensure a directory exists for our custom selinux module
|
2024-12-17 15:31:55 +10:00
|
|
|
ansible.builtin.file: dest=/usr/share/collectd state=directory
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:10:34 +00:00
|
|
|
- selinux
|
2014-07-18 19:38:00 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Copy over our general collectd selinux module
|
2024-12-18 08:23:28 +10:00
|
|
|
ansible.builtin.copy: src=selinux/fi-collectd.pp dest=/usr/share/collectd/fi-collectd.pp
|
2014-11-17 15:05:40 +00:00
|
|
|
register: ficgeneral_module
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:10:34 +00:00
|
|
|
- selinux
|
2014-07-18 19:38:00 +00:00
|
|
|
|
2023-05-26 12:20:52 +02:00
|
|
|
# TODO: consider using selinux_modules from https://galaxy.ansible.com/linux-system-roles/selinux instead
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Check to see what version is installed (if any)
|
2024-12-19 16:42:30 +10:00
|
|
|
ansible.builtin.shell: "semodule -l -m | grep fi-collectd | cut -d: -f2"
|
2023-05-26 12:20:52 +02:00
|
|
|
register: ficgeneral_installed_version
|
2016-11-01 16:29:49 +00:00
|
|
|
check_mode: no
|
2023-05-26 12:20:52 +02:00
|
|
|
changed_when: false
|
|
|
|
tags:
|
|
|
|
- collectd
|
|
|
|
- selinux
|
|
|
|
|
|
|
|
# This cmd comes from the last example of the semodule man page
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Check to see what version we have
|
2024-12-19 16:42:30 +10:00
|
|
|
ansible.builtin.shell: /usr/libexec/selinux/hll/pp /usr/share/collectd/fi-collectd.pp | sha256sum | cut -d ' ' -f1
|
2023-05-26 12:20:52 +02:00
|
|
|
register: ficgeneral_local_version
|
|
|
|
check_mode: no
|
|
|
|
changed_when: false
|
2014-11-05 15:40:47 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:05:40 +00:00
|
|
|
- selinux
|
2014-11-05 15:40:47 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install our general collectd selinux module
|
2024-12-19 11:22:24 +10:00
|
|
|
ansible.builtin.command: semodule -i /usr/share/collectd/fi-collectd.pp
|
2023-05-26 12:20:52 +02:00
|
|
|
when: ficgeneral_module is changed or ficgeneral_installed_version != ficgeneral_local_version
|
2014-10-01 19:38:16 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:05:40 +00:00
|
|
|
- selinux
|
2014-07-18 19:38:00 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Copy over our pstorefs/collectd selinux module (rhel6 has no pstorefs)
|
2024-12-18 08:23:28 +10:00
|
|
|
ansible.builtin.copy: src=selinux/fi-pstorefs.pp dest=/usr/share/collectd/fi-pstorefs.pp
|
2014-11-17 15:05:40 +00:00
|
|
|
register: ficpstorefs_module
|
2014-11-05 16:04:43 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:05:40 +00:00
|
|
|
- selinux
|
2014-11-05 16:04:43 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Check to see if its even installed yet
|
2024-12-19 16:42:30 +10:00
|
|
|
ansible.builtin.shell: semodule -l | grep fi-pstorefs | wc -l
|
2014-11-17 15:05:40 +00:00
|
|
|
register: ficpstorefs_grep
|
2016-11-01 16:29:49 +00:00
|
|
|
check_mode: no
|
2014-11-17 15:06:52 +00:00
|
|
|
changed_when: "'0' in ficpstorefs_grep.stdout"
|
2014-11-05 16:04:43 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:05:40 +00:00
|
|
|
- selinux
|
2014-11-05 16:04:43 +00:00
|
|
|
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Install our pstorefs/collectd selinux module
|
2024-12-19 11:22:24 +10:00
|
|
|
ansible.builtin.command: semodule -i /usr/share/collectd/fi-pstorefs.pp
|
2023-01-10 14:35:18 -08:00
|
|
|
when: (ficpstorefs_module is changed or ficpstorefs_grep is changed)
|
2014-11-05 16:04:43 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|
2014-11-17 15:05:40 +00:00
|
|
|
- selinux
|
2014-11-05 16:04:43 +00:00
|
|
|
|
2013-06-07 19:36:29 +00:00
|
|
|
# each of the below should move to a separate task list
|
|
|
|
# since they are odd-balls and one-offs
|
|
|
|
|
|
|
|
# memcached - memcached only
|
|
|
|
|
|
|
|
# postgres - this is a conn check
|
2016-08-08 19:42:36 +00:00
|
|
|
## add /usr/share/collectd/pgconn-types.db
|
2013-06-07 19:36:29 +00:00
|
|
|
|
|
|
|
# openvpn - for bastion/openvpn gateways only
|
|
|
|
|
|
|
|
# mysql
|
|
|
|
## collectd-mysql
|
|
|
|
|
|
|
|
# haproxy
|
|
|
|
## add /usr/share/collectd/haproxy-types.db
|
|
|
|
## add socat pkg
|
2016-08-08 19:42:36 +00:00
|
|
|
##
|
2013-06-07 19:36:29 +00:00
|
|
|
|
|
|
|
# webproxy
|
|
|
|
|
2016-12-01 03:52:21 +00:00
|
|
|
# enable collectd
|
2025-01-14 20:18:57 +10:00
|
|
|
- name: Enable collectd svc
|
2017-04-13 01:37:21 +00:00
|
|
|
service: state=started enabled=true name=collectd
|
2016-12-01 03:52:21 +00:00
|
|
|
tags:
|
|
|
|
- collectd
|