Commit Graph

977 Commits (29d65dd0d5454d38591427144c765fa2acc9a5e5)

Author SHA1 Message Date
Dustin 57702bb9c7 hosts: vmhost[01]: Update static DNS server address 2022-12-18 20:19:32 -06:00
Dustin caef7f342b vm-hosts: Update autostart list
* Remove DC0 (decommissioned)
* Remove Jenkins and its build VMs (Migrated to Kubernetes)
* Add pxe0 (Required for Basement HUD)
2022-12-18 19:55:48 -06:00
Dustin cdc120bb07 ci: Add metricspi pipeline 2022-12-18 19:30:00 -06:00
Dustin 77c6408187 metricspi: Remove sensors scrape job
Sensor data are retrieved via Home Assistant.
2022-12-18 19:16:10 -06:00
Dustin da2b3c4d59 hosts: Remove dc0
Finally got this guy shut down!
2022-12-18 19:12:58 -06:00
Dustin a670e34e90 r/homeassistant: Proxy for Zigbee2MQTT frontend
Zigbee2MQTT now has a web GUI, which makes it *way* easier to manage the
Zigbee network.  Now that I've got all the Philips Hue bulbs controlled
by Zigbee2MQTT instead of the Hue Hub, having access to the GUI is
awesome.
2022-12-12 17:47:05 -06:00
Dustin bdd0310cf6 ci: lib: Update for latest ansible container image
The latest version of the *ansible* container runs processes as the
unprivileged *jenkins* user, provides its own "sleep forever" default
command, and sets the correct LANG environment variable.  Since it runs
processes as *jenkins*, we need to override HOME and set it to the
WORKSPACE to ensure Jenkins has a writable path for arbitrary files.
2022-12-03 13:36:10 -06:00
Dustin 244482ac52 websites: Add hatchlearningcenter.org
This is the website for Tabitha's new hybrid private school! 👩‍🎓
2022-11-30 22:04:29 -06:00
Dustin 11e26c3189 hosts: Remove jenkins0, build0
The Jenkins controller is now hosted in Kubernetes.  Relatedly, jobs
all run in Kubernetes pods, and there is no longer any need for static
agents.
2022-11-27 17:21:03 -06:00
Dustin 772f669ab2 r/gitea: Handle encoded / characters in HTTP paths
Gitea package names (e.g. OCI images, etc.) can contain `/` charactres.
These are encoded as %2F in request paths.  Apache needs to forward
these sequences to the Gitea server without decoding them.
Unfortunately, the `AllowEncodedSlashes` setting, which controls this
behavior, is a per-virtualhost setting that is *not* inherited from the
main server configuration, and therefore must be explicitly set inside
the `VirtualHost` block.  This means Gitea needs its own virtual host
definition, and cannot rely on the default virtual host.
2022-11-27 17:21:03 -06:00
Dustin c625b28d6d ci: radius: Convert to using shared library 2022-11-09 21:37:01 -06:00
Dustin 42830c1d5b ci: samba-dc: Convert to using shared library 2022-11-09 21:36:23 -06:00
Dustin eff98691fe ci: smtp: Convert to using shared library 2022-11-09 21:35:18 -06:00
Dustin db28544824 ci: ntp: Convert to using shared library 2022-11-09 21:31:53 -06:00
Dustin 6af78aadda ci: Set LANG environment variable
Hopefully this will fix this warning from Ansible:

> [WARNING]: An error occurred while calling
> ansible.utils.display.initialize_locale (unsupported locale setting).
> This may result in incorrectly calculated text widths that can cause
> Display to print incorrect line lengths
2022-11-09 21:24:29 -06:00
Dustin 9286e431ab ci: Use SSH host keys from ssh-hostkeys role
I don't know why I didn't think of this before!  There's no reason to
have to have already copied the `ssh_known_hosts` file from to
`/etc/ssh` before running `ansible-playbook`.  In fact, keys just end up
getting copied from `/etc/ssh/ssh_known_hosts` into `~/.ssh/known_hosts`
anyway.  So let's just make it so that step isn't necessary: copy the
host key database directly to `~/.ssh` and avoid the trouble.
2022-11-09 21:16:21 -06:00
Dustin 8cc909baba ci: Run in Kubernetes instead of Docker
We'll use the `podTemplate` block to define an ephemeral agent running in
a Kubernetes pod as the node for this pipeline.  This takes the place of
the Docker container we used previously.
2022-11-09 20:59:07 -06:00
Dustin e09e684fd8 hosts: Update mtrcs0 FQDN
I moved the metrics Pi from the red network to the blue network.  I
started to get uncormfortable with the firewall changes that were
required to host a service on the red network.  I think it makes the
most sense to define the red network as egress only.
2022-11-09 18:56:05 -06:00
Dustin 0e97d5e39f r/gitea: Update to 1.17.0
The only major change that affects the configuration policy is the
introduction of the `webhook.ALLOWED_HOST_LIST` setting.  For some dumb
reason, the default value of this setting *denies* access to machines on
the local network.  This makes no sense; why do they expect you to host
your CI or whatever on a *public* network?  Of course, the only reason
given is "for security reasons."
2022-09-01 17:29:34 -05:00
Dustin 8965ede50a r/samba-dc: Remove winbindd restorecon workaround
This work-around is no longer necessary as the default Fedora policy now
covers the Samba DC daemon.  It never really worked correctly, anyway,
because Samba doesn't start `winbindd` fast enough for the
`/run/samba/winbindd` directory to be created before systemd spawns the
`restorecon` process, so it would usually fail to start the service the
first time after a reboot.
2022-08-22 20:32:07 -05:00
Dustin 2ca92f68f7 r/frigate: Restart service if it fails
Sometimes, Frigate crashes in situations that should be recoverable or
temporary.  For example, it will fail to start if the MQTT server is
unreachable initially, and does not attempt to connect more than once.
To avoid having to manually restart the service once the MQTT server is
ready, we can configure the systemd unit to enable automatic restarts.
2022-08-22 20:08:09 -05:00
Dustin 1834f9a108 r/bitwarden_rs: Remove dangling container at start
If the *vaultwarden* service terminates unexpectedly, e.g. due to a
power loss, `podman` may not successfully remove the container.  We
therefore need to try to delete it before starting it again, or `podman`
will exit with an error because the container already exists.
2022-08-22 20:06:02 -05:00
Dustin 4511d5447e vm-hosts: Add missing kube.network config
When I added the *systemd-networkd* configuration for the Kubernetes
network interface on the VM hosts, I only added the `.netdev`
configuration and forgot the `.network` part.  Without the latter,
*systemd-networkd* creates the interface, but does not configure or
activate it, so it is not able to handle traffic for the VMs attached to
the bridge.
2022-08-22 20:00:47 -05:00
Dustin 31c73e696f r/z*2mqtt: Restart services after unexpected stop
Both *zwavejs2mqtt* and *zigbee2mqtt* have various bugs that can cause
them to crash in the face of errors that should be recoverable.
Specifically, when there are network errors, the processes do not always
handle these well.  Especially during first startup, they tend to crash
instead of retry.  Thus, we'll move the retry logic into systemd.
2022-08-21 22:25:12 -05:00
Dustin 465aa4d78e r/z*2mqtt: Wait for clock to sync before starting
The *zwavejs2mqtt* and *zigbee2mqtt* services need to wait until the
system clock is fully synchronized before starting.  If the system clock
is wrong, they may fail to validate the MQTT server certificate.

The *time-sync.target* unit is not started until after services that
sync the clock, e.g. using NTP.  Notably, the *chrony-wait.service* unit
delays *time-sync.target* until `chrony waitsync` returns.
2022-08-21 21:58:30 -05:00
Dustin 7044cf3a46 r/hass-dhcp: Start dnsmasq after network is up
The *vlan99* interface needs to be created and activated by
`systemd-networkd` before `dnsmasq` can start and bind to it.  Ordering
the *dnsmasq.service* unit after *network.target* and
*network-online.target* should ensure that this is the case.
2022-08-21 08:03:00 -05:00
Dustin b8b8ae5798 vm-hosts: Define machines to auto start 2022-08-20 21:19:01 -05:00
Dustin 0cd58564c9 r/vmhost: Add autostart script
*libvirt*'s native autostart functionality does not work well for
machines that migrate between hosts.  Machines lose their auto-start
flag when they are migrated, and the flag is not restored if they are
migrated back.  This makes the feature pretty useless for us.

To work around this limitation, I've added a script that is run during
boot that will start the machines listed in `/etc/vm-autostart`, if they
exist.  That file can also insert a delay between starting two machines,
which may be useful to allow services to fully start on one machine
before starting another that may depend on them.
2022-08-20 21:15:31 -05:00
Dustin a433d1b01b hosts: remove dns0.p.b
I've moved handling of DNS to the border firewall instead of a dedicated
virtual machine.  Originally, the VM was necessary because the UniFi
Security Gateway sucked and could not (easily) handle the complex
configuration I wanted to use.  Since moving to the new firewall, this
is no longer a problem.

Having DNS on a VM is problematic when full-network outages occur, like
the one that happened on 16 August 2022.  When everything starts back
up, DNS is unavailable.  libvirt VM autostart does not work for machines
that have been migrated between hosts (the auto-start flag is not
migrated, and libvirt "forgets" that the VM was supposed to autostart if
it is migrated away and back).  I plan to script a solution for this at
some point, but I still think it makes more sense for the firewall to
handle it.  It will certainly make it come up quicker regardless.
2022-08-20 18:20:06 -05:00
Dustin bc60451949 metricspi: Update DNS server address
DNS is now handled by the border firewall.
2022-08-20 18:19:13 -05:00
Dustin a34debbdd5 r/named: Fix typo in firewalld condition 2022-08-20 18:18:38 -05:00
Dustin b7bbafd189 r/protonvpn: Move remote_addrs file to /var
If `/` is mounted read-only, as is usually the case, the Proton VPN
watchdog cannot update the `remote_addrs` configuration file.  It needs
to be stored in a directory that is guaranteed to be writable.
2022-08-20 18:18:21 -05:00
Dustin b6a35f9ce9 r/protonvpn: Install watchdog dependencies
The `protonvpn-watchdog.py` script requires the *httpx* Python package.
This needs to be installed for the script to work.
2022-08-20 18:14:31 -05:00
Dustin 9c364b1f06 r/netboot/basementhud: Configure NBD export
The *netboot/basementhud* Ansible role configures two network block
devices for the basement HUD machine:

* The immutable root filesystem
* An ephemeral swap device
2022-08-15 17:18:48 -05:00
Dustin 4622240c6c r/netboot/jenkins-agent: Configure NBD exports
The *netboot/jenkins-agent* Ansible role configures three NBD exports:

* A single, shared, read-only export containing the Jenkins agent root
  filesystem, as a SquashFS filesystem
* For each defined agent host, a writable data volume for Jenkins
  workspaces
* For each defined agent host, a writable data volume for Docker

Agent hosts must have some kind of unique value to identify their
persistent data volumes.  Raspberry Pi devices, for example, can use the
SoC serial number.
2022-08-15 17:14:06 -05:00
Dustin 20fd03795b hosts: add pxe0.p.b
*pxe0.pyrocufflink.blue* hosts TFTP and NBD for network-booted devices.
2022-08-15 17:13:56 -05:00
Dustin 02e4df023c r/pxe: Set up a PXE server
The *pxe* role configures the TFTP and NBD stages of PXE network
booting.  The TFTP server provides the files used for the boot stage,
which may either be a kernel and initramfs, or another bootloader like
SYSLINUX/PXELINUX or GRUB.  The NBD server provides the root filesystem,
typically mounted by code in early userspace/initramfs.

The *pxe* role also creates a user group called *pxeadmins*.  Users in
this group can publish content via TFTP; they have write-access to the
`/var/lib/tftpboot` directory.
2022-08-15 17:12:35 -05:00
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