Commit Graph

890 Commits (3214d4b9b2a69cd557d4532c3011991ff6025d04)

Author SHA1 Message Date
Dustin 5a284faa5c r/tftp: Deploy TFTP server
The *tftp* role installs the *tftp-server* package.  There is
practically no configuration for the TFTP server.  It "just works" out
of the box, as long as its target directory exists.
2022-08-15 17:06:20 -05:00
Dustin 14bfddd0ee r/nbd-server: Deploy nbd-server
The *nbd-server* role configures a machine as a Network Block Device
(NDB) server, using the reference `nbd-server` implementation.  It
configures a systemd socket unit to listen on the port and accept
incoming connections, and a template service unit for systemd to
instantiate and pass each incoming connection.

The reference `nbd-server` is actually not very good.  It does not clean
up closed connections reliably, especially if the client disconnects
unexpectedly.  Fortunately, systemd provides the necessary tools to work
around these bugs.  Specifically, spawning one process per connection
allows processes to be killed externally.  Further, since systemd
creates the listening socket, it can control the keep-alive interval.
By setting this to a rather low value, we can clean up server processes
for disconnected clients more quickly.

Configuration of the server itself is minimal; most of the configuration
is done on a per-export basis using drop-in configuration files.  Other
Ansible roles should create these configuration files to configure
application-specific exports.  Nothing needs to be reloaded or restarted
for changes to take effect; the next incoming connection will spawn a
new process, which will use the latest configuration file automatically.
2022-08-15 16:55:36 -05:00
Dustin cfffd1d782 collectd: Only configure SELinux when used
The `selinux_permissive` module fails on hosts that do not have SELinux
activated.  We must skip running this task on those machines to avoid
fatal errors.
2022-08-14 19:39:02 -05:00
Dustin 82f2a7518e r/system-auth: Disable authselect
*authselect* is now [mandatory][0] in Fedora 36.  It cannot be
uninstalled, but it can be disabled by removing its configuration file.

[0]: https://fedoraproject.org/wiki/Changes/Make_Authselect_Mandatory
2022-08-12 16:54:00 -05:00
Dustin 0de1f84905 r/frigate: Wait for network before starting service
Frigate needs to be able to connect to the MQTT immediately upon start
up or it will crash.  Ordering the *frigate.service* unit after
*network-online.target* will help ensure Frigate starts when the system
boots.
2022-08-12 16:24:28 -05:00
Dustin dbc18022f2 metricspi: Increase scrape_timeout for speedtest
Running the Internet speed test can often take longer than a minute.
2022-08-12 14:54:49 -05:00
Dustin de93ccb0da r/systemd-resolved: Manage systemd resolver daemon
The *systemd-resolved* role/playbook ensures the *systemd-resolved*
service is enabled and running, and ensures that the `/etc/resolv.conf`
file is a symlink to the appropriate managed configuration file.
2022-08-12 14:35:14 -05:00
Dustin 921cf653b8 remount: Do not remount SquashFS volumes
SquashFS volumes, naturally, cannot be remounted read-write.
2022-08-12 13:40:06 -05:00
Dustin 37a205e8a0 ci: lib: Configure SSH key for Ansible
In order for Jenkins to apply configuration policy on machines that are
not members of the *pyrocufflink.blue* domain, it needs to use an SSH
private key for authentication.
2022-08-12 13:30:22 -05:00
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