Commit Graph

1122 Commits (59d17bf3f4b8e350248af53b7f75d4899dcbf0cf)

Author SHA1 Message Date
Dustin a5e2920223 r/victoria-logs: Update to v1.23.3 2025-06-03 18:59:25 -05:00
Dustin 3df5b06169 site: Import victoria-logs PB 2025-05-30 21:52:23 -05:00
Dustin d4d3f0ef81 r/victoria-logs: Deploy VictoriaLogs
I've become rather frusted witih Grafana Loki lately.  It has several
bugs that affect my usage, including issues with counting and
aggregation, completely broken retention and cleanup, spamming itself
with bogus error log messages, and more.  Now that VitoriaLogs has
first-class support in Grafana and support for alerts, it seems like a
good time to try it out.  It's under very active development, with bugs
getting fixed extremely quickly, and new features added constantly.
Indeed, as I was experimenting with it, I thought, "it would be nice if
the web UI could decode ANSI escapes for terminal colors," and just a
few days later, that feature was added!  Native support for syslog is
also a huge benefit, as it will allow me to collect logs directly from
network devices, without first collecting them into a file on the Unifi
controller.

This new role deploys VictoriaLogs in a manner very similar to how I
have Loki set up, as a systemd-managed Podman container.   As it has no
built-in authentication or authorization, we rely on Caddy to handle
that.  As with Loki, mTLS is used to prevent anonymous access to
querying the logs, however, authentication via Authelia is also an
option for human+browser usage.  I'm re-using the same certificate
authority as with Loki to simplify Grafana configuration.  Eventually, I
would like to have a more robust PKI, probably using OpenBao, at which
point I will (hopefully) have decided which log database I will be
using, and can use a proper CA for it.
2025-05-30 21:19:05 -05:00
Dustin 1768678213 frigate: Set logout URL
Although I'm sure it will never be used, we might as well set the logout
URL to the correct value.  When the link is clicked, the browser will
navigate to the Authelia logout page, which will invalidate all SSO
sessions.
2025-04-21 08:28:49 -05:00
Dustin 57c5afc0c8 r/frigate: Fix Authelia redirect
HTTP 301 is "moved permanently." Browsers will cache this response and
never send the request to the real server again.  We need to use a
temporary redirect, such as "see other" to avoid getting stuck in a
login loop.
2025-04-21 08:27:34 -05:00
Dustin 113ffa2b96 r/frigate: Update to v0.15
Frigate has evolved a lot over the past year or so since v0.13.
Notably, some of the configuration options have been renamed, and
_events_ have become _alerts_ and _detections_.  There's also now
support for authenication, though we don't need it because we're using
Authelia.
2025-04-20 16:23:04 -05:00
Dustin 1b94530b1f frigate: Add front yard camera
We're trying to sell the Hustler lawn mower, so we plan to set it out
at the end of the driveway for passers-by to see.  I've temporarily
installed one of the Annke cameras in the kitchen, pointed out the
front window, to monitor it.
2025-04-20 14:10:27 -05:00
Dustin 641ddf8613 site: Import restic playbook
This will automatically configure backups on new machines that should
have them.
2025-03-29 09:37:55 -05:00
Dustin 6df0cc39da unifi: Back up with Restic
The Unifi Network data will now be backed up by Restic.
2025-03-29 09:36:37 -05:00
Dustin 572022b557 restic: Trust dch-root-ca certificate
Since the MinIO server that Restic uses to store snapshots has a
certificate signed by the DCH CA, we need to trust the root certificate
in order to communicate with it.  Existing servers already had this CA
trusted by the `pyrocufflink.yml` playbook, but new servers are not
(usually) AD domain members anymore, so we need to be explicit now.
2025-03-29 09:34:17 -05:00
Dustin daa59bdba5 r/useproxy: Configure dnf to use proxy
Although running `dnf` from the command line works without explicitly
configuring the proxy, because it inherits the environment variables set
by PAM on login from the user's shell, the `dnf` Ansible module does
not, as it does not inherit those variables.  Thus, we need to
explicitly configure the `proxy` setting in `dnf.conf` in order to be
able to install packages via Ansible.

Since `dnf` does not have separate settings for different protocols
(e.g. HTTP, HTTPS, FTP), we need a way to specify which of the
configured proxies to use if there are multiple.  As such, the
*useproxy* role will attempt to use the value of the `dnf_proxy`
variable, if it is set, falling back to `yum_proxy` and finally
`http_proxy`.  This should cover most situations without any explicit
configuration, but allows flexibility for other cases.
2025-03-29 09:30:08 -05:00
Dustin cdd64b6309 unifi: Fix Promtail log scrape paths
The linuxserver.io Unifi container stored Unifi server and device logs
under `/var/lib/unifi/logs`, while the new container stores them under
`/var/log/unifi`.
2025-03-29 09:28:48 -05:00
Dustin 923c8a3ebc r/unifi: Open firewall port for syslog server
The Unifi Network controller runs a syslog server (listening on UDP port
5514) where Unifi devices can send their logs.  We need to open the port
in the firewall in order for it to receive log messages and write them
to disk.
2025-03-29 09:27:28 -05:00
Dustin 00acc54402 Merge branch 'unifi-redux' 2025-03-29 08:03:39 -05:00
Dustin 0c070c9807 gw1/squid: Allow Unifi controller to internal repos
I've move the Unifi controller back to running on a Fedora Linux
machine.  It therefore needs access to Fedora RPM repositories, as well
as the internal "dch" RPM repository, for system packages.

I also created a new custom container image for the Unifi Network
software (the linuxserver.io one sucks), so the server needs access to
the OCI repo on Gitea.
2025-03-29 08:01:50 -05:00
Dustin 0a956297c1 r/vmhost: Update for latest libvirt
Some time ago, _libvirt_ was refactored to use separate daemons and
sockets for each of its responsibilities, and the original "monolithic"
`libvirtd` was made obsolete.  The Fedora packages have more recently
been adjusted to favor this new approach, and now default to omitting
the monolithic daemon entirely (when `install_weak_deps` is disabled).

One interesting packaging snafu, though, is that without the weak
dependencies, there is _no_ way for clients to connect by default.
Clients run `which virt-ssh-helper` to see if it is installed, which it
is, but `which` is not.  They then fall back to running `nc`, which is
_also_ not installed.  So even though the tools they actually need are
present, their logic for detecting this is broken.  As such, we need to
explicitly install `which` to satisfy them.
2025-03-29 07:34:58 -05:00
Dustin 78d70af574 hosts: Add Unifi controllers to needproxy group
Since the network device management network does not have access to the
Internet, the Unifi controller machines must access it via the proxy.
2025-03-19 07:50:52 -05:00
Dustin 3877547c03 bootstrap: Import useproxy playbook
Hosts that must use the proxy in order to access the Internet need to
have that configured very early on, before any package installation is
attempted.
2025-03-19 07:46:28 -05:00
Dustin e76bc2c36c host-setup: Import users playbook
This ensures that default users are created on all new hosts during
initial provisioning.
2025-03-16 17:17:00 -05:00
Dustin 2e1cc6a130 site: Import UniFi playbook 2025-03-16 17:17:00 -05:00
Dustin db5d1fb91a unifi: Switch from nginx to Caddy
Mostly for built-in ACME support.
2025-03-16 17:17:00 -05:00
Dustin fbbe86c651 r/unifi: Do not deploy exporter
The _unifi_exporter_ has been broken since several versions of UniFi
Network ago.
2025-03-16 16:40:57 -05:00
Dustin db54b03aa8 r/unifi: Switching to custom container image
The _linuxserver.io_ image for UniFi Network is deprecated.  It sucked
anyway.  I've created a simple image based on Debian that installs the
_unifi_ package from the upstream apt repository.  This image doesn't
require running anything as _root_, so it doesn't need a user namespace.
2025-03-16 16:40:57 -05:00
Dustin a423826fcd newvm: Add host to some groups by default
There are some groups that all hosts should belong to in almost all
cases.  Rather than have to remember to add the `--group` arguments for
each of these, the `newvm.sh` script will now enable them by default.
For hosts that should _not_ belong to (at least one of) these groups,
the `--no-default-groups` argument can be provided to suppress that
behavior.

The default groups, initially, are _chrony_ and _collectd_.
2025-03-16 16:37:19 -05:00
Dustin c300dc1b6c chrony: Add role/PB for chrony
I continually struggle with machines' (physical and virtual, even the
Roku devices!) clocks getting out of sync.  I have been putting off
fixing this because I wanted to set up a Windows-compatible NTP server
(i.e. on the domain controllers, with Kerberos signing), but there's
really no reason to wait for that to fix the clocks on all the
non-Windows machines, especially since there are exactly 0 Windows
machines on the network right now.

The *chrony* role and corresponding `chrony.yml` playbook are generic,
configured via the `chrony_pools`, `chrony_servers`, and `chrony_allow`
variables.  The values for these variables will configure the firewall
to act as an NTP server, synchronizing with the NTP pool on the
Internet, while all other machines will synchronize with it.  This
allows machines on networks without Internet access to keep their clocks
in sync.
2025-03-16 16:37:19 -05:00
Dustin 4ba5f2ced0 hosts.gw: Add gw1 to sudo group
The default privilege elevation tool is now `doas`, but _gw1_ uses
`sudo`.
2025-03-16 16:37:19 -05:00
Dustin e4a4944fbc postgresql: Add receipts/user DB
The Receipt application needs a PostgreSQL database on the central
server.
2025-03-16 14:47:30 -05:00
Dustin fd59f3ebb2 users: Do not create users on domain members
The point of the `users.yml` playbook is to manage static users for
machines that are not members of the AD domain.  Since this playbook is
included in `site.yml`, it gets applied to _all_ machines, even those
that _are_ (or will become) domain members.  Thus, we want to avoid
actually doing anything on those machines.
2025-02-25 21:03:59 -06:00
Dustin 5f4b1627db hosts: Add nut1.p.b to pyrocufflink group
*nut1.pyrocufflink.blue* is a member of the *pyrocufflink.blue* AD
domain.  I'm not sure how it got to be so without belonging to the
_pyrocufflink_ Ansible group...
2025-02-25 21:03:14 -06:00
Dustin 9ea8756610 inventory: Exclude test machines by default
We don't want Jenkins attemptying to manage test VMs.  I thought of
various ways to exclude them, but in the end, I think a simple name
match will work fine.

The host provisioner _should_ manage test VMs, though, so it will need
to be configured to set the `PYROCUFFLINK_EXCLUDE_TEST` environment
variable to `false` to override the default behavior.
2025-02-14 10:04:48 -06:00
Dustin 6ae3404b3a vmhost: Allow host provisioner to log in
This commit adds tasks to the `vmhost.yml` playbook to ensure the
*jenkins* user has the Host Provisioner's SSH key in its
`authorized_keys` file.  This allows the Host Provisioner to log in and
access the read-only _libvirt_ socket in order to construct the dynamic
Ansible inventory.
2025-02-08 16:49:14 -06:00
Dustin 757494b48b newvm: Use kickstart from Gitea by default
The canonical location for kickstart scripts has _finally_ moved to
a real server instead of my desktop...
2025-02-08 16:49:14 -06:00
Dustin e7de5142f3 newvm: Allow setting cfgpol branch
The script that runs on first boot of a new machine that triggers
host provisioning can read the name of the configuration policy branch
to checkout from the QEMU firmware configuration option.  This commit
adds a `--cfg-branch` argument to `newvm.sh` that sets that value.  This
will be useful for testing new policy on a new VM.
2025-02-08 16:49:14 -06:00
Dustin 4d30798f54 newvm: Configure VM for dynamic inventory
This commit adds a new `--group` argument to the `newvm` script, which
adds the host to an Ansible group by listing it in the _libvirt_ domain
metadata.  Multiple groups can be specified by repeating the argument.
Additionally, the VM title is now always set to machine's FQDN, which
is what the dynamic inventory plugin uses to determine the inventory
hostname.

The dynamic inventory plugin parses the _libvirt_ domain metadata and
extracts group membership from the `<dch:groups>` XML element.  Each
`<dch:group>` sub-element specifies a group to which the host belongs.

Unfortunately, `virt-install` does not support modifying the
`<metadata>` element in the _libvirt_ domain XML document, so we have
to resort to using `virsh`.  To ensure the metadata are set before the
guest OS boots and tries to access them, we fork and run `virsh` in
a separate process.
2025-02-08 15:35:34 -06:00
Dustin 7ff18ab75e Introduce dynamic inventory
In order to fully automate host provisioning, we need to eliminate the
manual step of adding hosts to the Ansible inventory.  Ansible has had
the _community.libvirt.libvirt_ inventory plugin for quite a while, but
by itself it is insufficient, as it has no way to add hosts to groups
dynamically.  It does expose the domain XML, but parsing that and
extracting group memberships from that using Jinja templates would be
pretty terrible.  Thus, I decided the easiest and most appropriate
option would be to develop my own dynamic inventory plugin.

* Supports multiple _libvirt_ servers
* Can connect to the read-only _libvirt_ socket
* Can optionally exclude VMs that are powered off
* Can exclude VMs based on their operating system (if the _libosinfo_
  metadata is specified in the domain metadata)
* Can add hosts to groups as specified in the domain metadata
* Exposes guest info as inventory host variables (requires QEMU guest
  agent running in the VM and does not work with a read-only _libvirt_
  connection)
2025-02-08 15:29:58 -06:00
Dustin e9d6020563 all: Set root authorized keys
The `root_authorized_keys` variable was originally defined only for the
*pyrocufflink* group.  This used to effectively be "all" machines, since
everything was a member of the AD domain.  Now that we're moving away
from that deployment model, we still want to have the break-glass
option, so we need to define the authorized keys for the _all_ group.
2025-02-08 15:29:57 -06:00
Dustin d916545e29 synapse: Remove group variables
This was the last group that had an entire file encrypted with Ansible
Vault.  Now that the Synapse server is long gone, rather than convert it
to having individually-encrypted values, we can get rid of it entirely.
2025-02-08 15:29:57 -06:00
Dustin 8bd0722422 pyrocufflink: Remove root password
While having a password set for _root_ provides a convenient way of
accessing a machine even if it is not available via SSH, using a static
password in this way is quite insecure and not worth the risk.  I may
try to come up with a better way to set a unique password for each
machine eventually, but for now, having this password here is too
dangerous to keep.
2025-02-08 15:29:57 -06:00
Dustin 6f37f1417f site: Add master site playbook
The `site.yml` playbook imports all of the other playbooks, providing a
way to deploy _everything_.  Normally, this would only be done for a
single host, as part of its initial provisioning, to quickly apply all
common configuration and any application-specific configuration for
whatever roles the host happens to hold.

The `host-setup.yml` playbook provides an entry point for configuring
all common configuration.  Basically anything we want to do to _every_
machine, regardless of its location or role.
2025-02-08 15:29:55 -06:00
Dustin 143c96074e callbacks: Enable ARA
[ARA Records Ansible][0] is a web-based reporting tool for Ansible.  It
consists of a callback plugin that submits task/playbook results to an
HTTP API and a browser GUI to display them.

[0]: https://ara.recordsansible.org/
2025-02-01 17:36:58 -06:00
Dustin 164d86d646 r/postgresql-data: Manage users and databases
This role can ensure PostgreSQL users and databases are created for
applications that are not themselves managed by Ansible.  Notably, we
need to do this for anything deployed in Kubernetes that uses the
central database server.
2025-02-01 17:36:58 -06:00
Dustin 34c1256f27 base: Factor out SSH host, user cert roles
Moving the SSH host and user certificate configuration roles out of
`base.yml` into their own playbooks.  This will make it easier to deploy
them separately, and target different sets of hosts.  The main driver
for this change is the OVH VPS; being external, it cannot communicate
with SSHCA and thus cannot have a signed host certificate.  As such, we
do not want to try to configure the SSHCA client on it at all.
2025-02-01 17:36:58 -06:00
Dustin a3a2dde6ab callbacks: Add ntfy callback plugin
This plugin sends a notification using _ntfy_ whenever a playbook
fails.  This will be useful especially for automated deployments when
the playbook was not launched manually.
2025-02-01 17:36:58 -06:00
Dustin f705e98fab hosts: Add k8s-iot-net-ctrl group
The *k8s-iot-net-ctrl* group is for the Raspberry Pi that has the Zigbee
and Z-Wave controllers connected to it.  This node runs the Zigbee2MQTT
and ZWaveJS2MQTT servers as Kubernetes pods.
2025-01-31 19:49:51 -06:00
Dustin b1c29fc12a hosts: Remove hostvds group
Since the _hostvds_ group is not defined in the static inventory but by
the OpenStack inventory plugin via `hostvds.openstack.yml`, when the
static inventory is used by itself, Ansible fails to load it with an
error:

> Section [vps:children] includes undefined group: hostvds

To fix this, we could explicitly define an empty _hostvds_ group in the
static inventory, but since we aren't currently running any HostVDS
instances, we might as well just get rid of it.
2025-01-31 19:45:58 -06:00
Dustin 878a099752 r/kubelet: Ensure iscsi service is running
The _iscsi.socket_ unit gets enabled by default with the
_iscsi-initiator-utils_ package is installed, but it won't start
automatically until the next boot.  Without this service running,
Longhorn volumes will not be able to attach to the node, so we need to
explicitly ensure it is running before any workloads are assigned to the
node.
2025-01-31 19:01:27 -06:00
Dustin a9a6a30e59 r/{cri-o,kubelet}: Support versioned packages
Fedora 41 introduced versioned package names for Kubernetes components,
including CRI-O.  The intent is to allow multiple versions of Kubernetes
to be available (but not necessarily installed) within a given Fedora
release.  In order to use these packages, we need to set the desired
Kubernetes version, via the new `kubernetes_version` Ansible variable.
2025-01-31 18:57:21 -06:00
Dustin cbc4d29bd6 r/base: Install python3-libdnf5
Fedora 41 uses _dnf5_ by default.  Being written in C, its Python API is
an optional feature that needs to be installed separately.
2025-01-31 18:55:58 -06:00
Dustin ec4fa25bd8 Merge remote-tracking branch 'refs/remotes/origin/master' 2025-01-30 21:15:40 -06:00
Dustin a58dbb74c5 r/vmhost: Clean up qemu packages
At some point, the _qemu-kvm_ package became a meta-package that
installs _everything_ QEMU-related.  All drivers, backends, frontends,
etc. get pulled in, which results in a huge amount of wasted space.
Recently, the VM hosts started getting alerts about their `/` filesystem
getting too full, which is how I discovered this.

We can dramatically reduce the disk space footprint by installing only
the "core" package and the drivers we need for our servers.

After making and applying this change, which marks the listed packages
as "leaf" installs, I then manually uninstalled the _qemu-kvm_ package.
This uninstalled everything else that is not specifically listed.
2025-01-28 17:36:35 -06:00