Commit Graph

631 Commits (5a9b9a8d98f111444c025cdd136570eb5261cae3)

Author SHA1 Message Date
Dustin 5a9b9a8d98 mtrcs0: Remove Ansible user/become settings
Jenkins still connects as *jenkins* and uses `sudo`, so we can't
hard-code the user to *root*.
2022-08-12 13:22:47 -05:00
Dustin b4f752acbd hosts: remove stats0
*stats0.pyrocufflink.blue* is being decommissioned.  It has been
completely replaced by *mtrcs0.pyrocufflink.red* at this point.
2022-08-12 13:18:04 -05:00
Dustin d2ee99daa6 mtrcs0: Update SSH host key
I committed the wrong SSH host key.  It was probably from before I
rebuilt the machine using a new SSD.
2022-08-12 13:15:01 -05:00
Dustin 7d323311f5 metricspi: Apply victoria-metrics-nginx role 2022-08-12 13:14:41 -05:00
Dustin 1f04813879 r/v-m-nginx: Prevent requesting reload
Remote systems should not be able to trigger a reload of the services
behind the reverse proxy.
2022-08-12 13:14:05 -05:00
Dustin ce3e88932d vmalert: Allow configuring http.pathPrefix
*vmalert* requires explicit configuration when it is behind a reverse
proxy.
2022-08-12 13:10:36 -05:00
Dustin fe87edea21 r/vmalert: Allow configuring external source URLs
The `-external.url` and `-external.alert.source` command line arguments
and their corresponding environment variables can be used to configure
the "Source" links associated with alerts created by `vmalert`.
2022-08-12 12:58:53 -05:00
Dustin c57500a9f4 metricspi: Update speedtest scrape target
The firewall hardware is too slow to run the *prometheus_speedtest*
program.  It always showed *way* lower speeds than were actually
available.  I've moved the service to the Kubernetes cluster and it
works a lot better there.
2022-08-12 12:55:52 -05:00
Dustin 887d462127 r/v-m-nginx: Proxy for other services too
The *metricspi* hosts several Victoria Metrics-adjacent applications.
These each expose their own HTTP interface that can be used for
debugging or introspecting state.  To make these accessible on the
network, the *victoria-metrics-nginx* role now configures `proxy_pass`
directives for them in its nginx configuration.
2022-08-12 11:59:25 -05:00
Dustin 7ac5493b63 smtp1.p.b: Allow SMTP relay from pyrocufflink.red
AlertManager running on *mtrcs0.pyrocufflink.red* needs to be able to
send e-mail through the SMTP relay.
2022-08-11 21:43:48 -05:00
Dustin 993e29c0fe r/scrape-collectd: collectd scrape targets config
The *scrape-collectd* role generates the
`/etc/prometheus/scrape-collectd.yml` file.  This file can be read by
Prometheus/Victoria Metrics/vmagent to identify the hosts running
*collectd* with the *write_prometheus* plugin, using the
`files_sd_configs` scrape configuration option.

All hosts in the *collectd-prometheus* group are listed as scrape
targets.
2022-08-11 21:40:19 -05:00
Dustin 4ddbc9f256 hosts: Add mtrcs0.p.r
*mtrcs0.pyrocufflink.red* is a Raspberry Pi CM4 on a Waveshare
CM4-IO-BASE-B carrier board with a NVMe SSD.  It runs a custom OS built
using Buildroot, and is not a member of the *pyrocufflink.blue* AD
domain.

*mtrcs0.p.r* hosts Victoria Metrics/`vmagent`, `vmalert`, AlertManager,
and Grafana.  I've created a unique group and playbook for it,
*metricspi*, to manage all these applications together.
2022-08-11 21:40:19 -05:00
Dustin 7c654031f0 r/grafana: Allow configuring LDAP CA cert
The `grafana_ldap_root_ca_cert` can be used to set the path to the root
CA certificate (bundle) Grafana uses to validate the certificate
presented by the configured LDAP server.  By default, Grafana uses the
system root CA trust store, but this variable can be used in situations
where this is not suitable.
2022-08-11 21:40:19 -05:00
Dustin b3403268a8 r/vmalert: Deploy vmalert
`vmalert` is a component of Victoria Metrics. It handles alerting and
recording rules, periodically executing queries and dispatching alerts
or writing aggregated data back to the TSDB.
2022-08-11 21:40:19 -05:00
Dustin 0dab3afc85 r/alertmanager: Deploy AlertManager
*AlertManager* is the component of the Prometheus ecosystem responsible
for sending alert notifications.
2022-08-10 22:18:53 -05:00
Dustin 1e14dd7905 r/blackbox-exporter: Deploy blackbox_exporter
The Prometheus *blackbox_exporter* is a tool that can perform arbitrary,
generic ICMP, TCP, or HTTP "probes" against external services.  This is
useful for applications that do not export their own metrics, and for
evaluating the health of protocol-level operations (e.g. TLS
certificate expiration).

The *blackbox-exporter* Ansible role installs and configures the
Blackbox Exporter on the target system.  It fetches the specified binary
release from Github and copies it to the remote machine.  It also
creates a systemd unit and configures the Blackbox exporter's "modules"
from the `blackbox_modules` Ansible variable.
2022-08-10 22:18:53 -05:00
Dustin 60505657f3 r/vmagent: Deploy vmagent
The *vmagent* role installs and configures the scraping and routing
agent used in the Victoria Metrics ecosystem.
2022-08-10 22:18:43 -05:00
Dustin 956a40f054 r/victoria-metrics-nginx: Add reverse proxy for V-M
The *victoria-metrics-nginx* role configures *nginx* as a reverse proxy
for Victoria Metrics.
2022-08-10 22:16:48 -05:00
Dustin 31fe128d48 r/collectd: Max unixsock plugin optional
Some hosts may not need this plugin, or may not have it installed.
Notably, it is not needed or used on my systems based on Buildroot,
since the only current use case for it is to keep track of the Fedora
version.
2022-08-10 21:55:54 -05:00
Dustin 4aedeef546 grafana: Redirect HTTP to HTTPS 2022-08-10 21:55:54 -05:00
Dustin ac127b4649 r/grafana: Ensure service starts at boot 2022-08-10 21:55:54 -05:00
Dustin 13e26ac64c r/grafana: Ensure configuration directory exists
The *grafana* package for Fedora creates `/etc/grafana`, but it is not
created by default on Buildroot-based systems.
2022-08-10 21:55:54 -05:00
Dustin 7e08fb66f7 r/nginx: Fix applying on Buildroot systems
There are a few minor differences between the way Fedora and Buildroot
package *nginx*:

* Fedora uses a user named *nginx* while buildroot uses *www-data*
* Buildroot uses a Debian-like configuration layout (with
  `sites-enabled` and `modules-enabled` directories)

This commit adjusts the *nginx* Ansible role to compensate for these
differences, eschewing Buildroot's configuration layout for the one used
by Fedora/Red Hat.
2022-08-10 21:55:54 -05:00
Dustin 0785fda26b r/v-m: Add role for Victoria Metrics
The *victoria-metrics* role deploys a single-server instance of the
Victoria Metrics time series database server.  It installs the selected
version by downloading the binary release from Github and copying it to
`/usr/local/sbin` on the managed node.  Scrape configuration is optional
and can be specified with the `scrape_configs` variable.
2022-08-10 19:47:12 -05:00
Dustin 8176eaf694 r/collectd-prometheus: Work w/o firewalld, selinux
Tasks that configure the SELinux policy obviously only make sense if the
host uses SELinux.  Similarly, if the host does not use FirewallD,
configuring firewall rules doesn't work.
2022-08-10 19:47:12 -05:00
Dustin 8f90d802f4 collectd: Only install collectd-version on Red Hat
Although the `collectd-version` script is fairly generic and *should*
work for most Linux distributions, it cannot be installed on machines
that a have an immutable root filesystem, e.g. Buildroot-based systems.
For Buildroot-based systems in particular, tracking the OS version makes
very little sense anyway.  If we do end up with hosts running an OS
besides either Fedora or Buildroot, we can re-evaluate how to deploy
this feature.
2022-08-10 19:47:12 -05:00
Dustin ad96dc2757 r/collectd: Manage collectd.d directory
The `/etc/collectd.d` directory is created by the RPM package on
machines running a Red Hat-based Linux distribution, but it may not
always be present on other machines.
2022-08-10 19:47:12 -05:00
Dustin a357b5dc08 r/ssh-hostkeys: Add SSH keys for K8s nodes
I forgot to add the SSH host keys for the nodes in the Kubernetes
cluster when I first added them to the inventory.
2022-08-10 19:47:12 -05:00
Dustin c48cc985b2 r/collectd: Ignore filesystems by path
In addition to ignoring particular types of filesystems, e.g. OverlayFS,
we can also ignore filesystems by their mount point.  This could be
useful, for example, for bind-mounted directories, such as those used on
Kubernetes nodes.
2022-08-05 18:56:48 -05:00
Dustin 8cab0b368e r/collectd: Ignore overlay filesystems
By default, the *df* pluggin for collectd, which monitors filesystem
usage, collects data about all mounted filesystems.  It can be
configured to ignore some filesystems, either by mount point, device, or
filesystem type.  We will uses this capability to avoid collecting data
about OverlayFS mounts, because by definition, they do not represent a
real filesystem, but one or more other mounted filesystems.  Collecting
data about these just creates useless metrics, especially on machines
that run containers.
2022-08-03 21:21:28 -05:00
Dustin 870baa3fcf remount: Remount read/write by default
Setting the `remount_state` variable to `rw` by default will allow the
`remount.yml` playbook to be "chained" with other playbooks, e.g.:

```
ansible-playbook -l kubelet remount.yml collectd.yml -b
```
2022-08-03 20:57:05 -05:00
Dustin 1214b507c5 r/collectd-prometheus: Skip firewalld tasks
Some machines, such as the nodes in the Kubernetes cluster, do not use
*firewalld*.  For these machines, we need to skip the `firewalld` tasks,
as they will fail.  The `host_uses_firewalld` variable can be set to
`False` for these machines to do so.
2022-08-03 20:57:05 -05:00
Dustin c8e89a4b16 hosts: Add Kubernetes machines
There is no specific playbook or role for Kubernetes.  All OS
configuration is done at install time via kickstart scripts, and
deploying Kubernetes itself is done (manually) using `kubeadm init` and
`kubeadm join`.
2022-08-03 20:52:01 -05:00
Dustin 3b692a9de8 vm-hosts: Add Kubernetes VLAN configuration 2022-08-03 20:51:33 -05:00
Dustin 6f95a595b2 hosts: Add nvr1.p.b to rw-root group
*nvr1.pyrocufflink.blue* has a single btrfs filesystem which cannot be
mounted read-only.
2022-07-24 16:44:06 -05:00
Dustin c9dbaa32b9 collectd: Control SELinux domain permissiveness
It seems with each new release of Fedora, some feature or other of
*collectd* gets broken.  In Feodra 36, the *interfaces* plugin does not
seem to work reliably, and the *md* plugin logs a *lot* of errors.
While these issues are investigated upstream, we either need to manage
our own policy for collectd or mark the `collectd_t` domain permissive.
I chose the latter because I'm lazy and I don't consider collectd to be
that big of a threat to security.
2022-07-24 10:35:32 -05:00
Dustin 6f11a4cf3a grafana: Set Grafana domain
Necessary for Grafana CSRF protection.
2022-07-24 10:31:46 -05:00
Dustin be4bbc0092 r/grafana: Fix Origin not allowed error
Grafana 8.3.5 introduced a new CSRF protection mechanism that requires
the value of the Host HTTP request header to be preserved from the
original client request.

https://github.com/grafana/grafana/issues/45117#issuecomment-1033842787
2022-07-24 10:07:45 -05:00
Dustin 3e8da609e7 frigate: Keep front porch recordings for 2 days
Now that there is plenty of storage in the new video server, let's keep
24/7 recordings from the front porch camera, too.
2022-07-23 17:52:26 -05:00
Dustin 797cc2092f hosts: Add nvr1.p.b
*nvr1.pyrocufflink.blue* is the new video recording server.  It is a
1U rack-mounted physical machine based on the [Jetway
JBC150F596-3160-B][0] barebone system.  It replaces
*nvr0.pyrocufflink.blue* in this role.

[0]: https://www.jetwaycomputer.com/JBC150F596.html
2022-07-23 17:52:26 -05:00
Dustin eb79f6ea83 r/frigate: Work around podman/netavark lock
Podman 4 puts lock files in the configuration directory for [some stupid
reason][0].  There are so many issues here!

* It is now impossible to run `podman` as root with a read-only `/etc`.
* Why does it need the lock file at all when using `--network=host`?

Luckily, we can work around it fairly easily by mounting a tmpfs
filesystem over the directory it wants to put the lock file in.  This
pretty much defeats the purpose of having a lock file, but it's likely
not needed anyway.

[0]: 836fa4c493
2022-07-23 17:43:54 -05:00
Dustin c1c28a51b5 frigate: Use native MQTT/TLS support
Frigate has native support for MQTT over TLS now, so there is no more
any need to use stunnel.
2022-07-23 17:27:02 -05:00
Dustin d5ef18ccc3 frigate: Split camera config into separate file
This will make it easier to manage Frigate camera settings.
2022-07-23 17:26:19 -05:00
Dustin ee0e6873ad r/collectd-sensors: Install collectd sensors plugin
The *sensors* plugin for collectd reads temperature information from the
I²C/SMBus using *lm_sensors*.  Naturally, it is only useful on physical
machines, so it is not installed or enabled by default.
2022-07-21 13:14:25 -05:00
Dustin 87e24aba3f hosts: hass2.p.b: Enable collectd thermal plugin
This plugin reads Raspberry Pi SoC temperature data.
2022-07-21 12:37:16 -05:00
Dustin a60327a995 r/collectd: Allow the thermal plugin
Raspberry Pi devices provide SoC temperature information through thermal
zone data in sysfs.
2022-07-21 12:37:07 -05:00
Dustin 29a6a0540f r/collectd: Better control over enabled plugins
Instead of a simple list of disabled plugins, hosts and host groups can
now control whether plugins are enabled or disabled using the
`collectd_plugins` map.  The map keys are plugin names, and the values
are booleans indicating if the plugin is enabled.

Using this mechanism, some plugins can be disabled by default (e.g. the
*md* plugin), and enabling them per host or per host group is simpler.
2022-07-21 12:22:19 -05:00
Dustin c7ca8e5b15 r/collectd: Allow enabling the md plugin
The *md* plugin monitors Linux multi-disk RAID (*mdraid*) devices.
2022-07-21 12:22:19 -05:00
Dustin 41582beef9 group_vars/frigate: Add second back yard camera
Adding a second camera to the back yard, on the North side of the porch,
to try and figure out how the possums keep getting under the porch even
with the chicken wire around it!
2022-07-18 18:25:20 -05:00
Dustin 82f9ce0797 group_vars/frigate: Keep back yard recordings
We're trying to discover how the possums are getting into and out of the
house.  Let's enable continuous video recording from the back yard
camera so we can observe them and come up with a plan to get rid of
them.
2022-07-18 18:20:21 -05:00