Commit Graph

784 Commits (wheelhost)

Author SHA1 Message Date
Dustin 19330ac555 r/protonvpn: watchdog: reconfigure at startup
If the remote address configuration for strongSwan is not valid when the
Proton VPN watchdog starts, it will now regenerate it immediately.  This
can happen, for example, if the Internet has been down for a while, and
the watchdog has iterated through all of the servers in the cache.
Restarting the service will now force it to reconfigure the tunnel and
bring the VPN back up.
2021-10-31 01:24:52 -05:00
Dustin 328f2fa586 hosts: Set up collectd/Prometheus on vmhosts
The groups in `hosts.offline` need to match those in `hosts`.
Specifically, the *collectd* group needs to be a child of the
*collectd-prometheus* group so that the *write_prometheus* plugin is
installed and configured on hosts defined in this inventory file.
2021-10-31 01:13:50 -05:00
Dustin 6c705f54af hosts: vmhost1: Switch to systemd-networkd
Using *systemd-networkd* to configure network interfaces on *vmhost0* is
working really well.  It is decidedly more stable than *dhcpcd* was, and
certainly easier to work with than NetworkManager.  Let's go ahead and
switch *vmhost1* as well.
2021-10-31 01:12:25 -05:00
Dustin d3592f1162 hosts: Add serial0.pyrocufflink.blue
This is a Raspberry Pi 3 on the DIN rail that has USB-to-RS232 adapters
connected to the VM hosts and the Firewall.
2021-10-31 00:54:10 -05:00
Dustin a178dc4af9 r/collectd-version: Add OS version plugin
The `collectd-version` script uses the *collectd* UNIX socket to send
custom values to *collectd* to track the OS version.  Since these values
obviously cannot change while the system is running, the values are
specified with a very long interval.  This avoids having to continuously
insert the values, either with a long-running process or by repeatedly
running a script.  The values only need to be inserted once when
*collectd* starts.
2021-10-30 16:50:37 -05:00
Dustin 12c3fb950b r/collectd: Add custom types database
All values sent to *collectd* must have an associated type.  The type
defines the acceptable range of values.  Types are defined in a simple
text file database.  *collectd* loads all of the databases specified by
`TypesDB` directives in its configuration file.  When configuring a
custom types database, the default database needs to be specified
explicitly; it will not be loaded automatically if there are any
`TypesDB` directives in the configuration.
2021-10-30 16:47:29 -05:00
Dustin 32d1e0ff6f r/collectd: Enable unixsock plugin
The *unixsock* plugin for *collectd* provides a socket-based interface
that other software can use to communicate with *collectd*.  Notably,
this can be used to publish custom values, query existing values, and
flush caches.

The socket is created at `/run/collectd/socket`.  The `/run/collectd`
directory is managed by systemd; it will be created automatically when
the service starts and cleaned up when it stops.
2021-10-30 16:46:01 -05:00
Dustin 98401b3c1e remount: Only remount if needed
Skip remounting filesystems that are already in the specified state.
2021-10-30 16:41:58 -05:00
Dustin 689d53abfd r/collectd: Disable network plugin by default
The default configuration for *collectd* no longer needs the network
plugin enabled, as hosts are scraped directly by Prometheus now.
2021-10-30 16:41:17 -05:00
Dustin 881c8de625 Switch Prometheus/collectd to pull
Transitioning from push-based to pull-based monitoring with
Prometheus/collectd.  The *write_prometheus* plugin will be installed on
all hosts, and Prometheus will be configured to scrape them directly.
2021-10-30 16:41:17 -05:00
Dustin b78af05fd8 r/collectd-prometheus: Allow scraping from outside
The *collectd-prometheus* role now has a
`collectd_prometheus_allow_outsize` variable.  This variable controls
whether or not external hosts are allowed to scrape data from *collectd*.
When set to `false`, as is the default value, *collectd* will be
configured to listen on the loopback interface only, and the TCP port
will not be opened in the firewall.
2021-10-30 16:41:17 -05:00
Dustin 3127b9b8f7 r/synapse: Enable Prometheus metrics
Synapse supports exporting metrics in Prometheus format.  It can do this
either as part of the main server, or in a separate listener.  I chose
to use a separate listener so that the metrics are not exposed
publicly.
2021-10-18 18:08:50 -05:00
Dustin 6df0d7bea4 r/gitea: Enable Prometheus metrics
Gitea provides a Prometheus-compatible metrics endpoint at `/metrics`,
but it is disabled by default.
2021-10-18 10:11:44 -05:00
Dustin d8919f6424 hosts: dns0: Allow DDNS updates from gw1
Since the firewall is now the DHCP server, the DNS server needs to allow
it to send DDNS updates for *pyrocufflink.red*.
2021-10-17 14:12:19 -05:00
Dustin 86aa292931 hosts: Remove dc2 from ntpd group
Fedora 34 does not include the *ntp* package, as it has been "obsoleted
by ntpsec."  Until I can create a role for *ntpsec*,
*dc2.pyrocufflink.blue* cannot be an NTP server.
2021-10-17 14:11:00 -05:00
Dustin 8eeccc0f65 hosts: dc2: Add RADIUS server certificate 2021-10-17 14:03:52 -05:00
Dustin 93bf6593d7 r/collectd: Add missing processes.conf template
I forgot to `git add` the template file.
2021-10-17 09:13:34 -05:00
Dustin f3c4b4d174 Merge remote-tracking branch 'refs/remotes/origin/master' 2021-10-16 21:54:36 -05:00
Dustin 8e9699810b burp-server: Monitor burp process with collectd 2021-10-16 21:53:51 -05:00
Dustin e2c5549f35 hosts: Add dc2.p.b
*dc2.pyrocufflink.blue* acts as a second Active Directory Domain
Controller with *samba*.
2021-10-16 21:53:02 -05:00
Dustin 8e35c57f53 samba-dc: Monitor processes with collectd
Monitor the state of Samba server processes via the *processes* plugin
for *collectd*.
2021-10-16 16:33:23 -05:00
Dustin d032e1b89d bitwarden_rs: Monitor processes with collectd
Monitor the state of the `bitwarden_rs` server process via the
*processes* plugin for *collectd*.
2021-10-16 16:32:22 -05:00
Dustin 3e08588d98 collectd: Configure the processes plugin
The *processes* plugin for collectd can be configured to monitor
additional information about specific processes.  By specifying one or
more `Process` or `ProcessMatch` directives in the plugin configuration,
collectd will start monitoring the listed processes in detail.

The `collectd_processes` Ansible variable can contain a list of
processes to monitor.  Each item must at least have a `name` property,
and may also have a `regex` property.  If the latter is present, a
`ProcessMatch` directive will be emitted instead of a `Process`
directive.
2021-10-16 16:25:02 -05:00
Dustin 014043909a vm-hosts: Enable multicast querier on bridge
Having this option enabled dramatically improves the reliability of
collectd multicast traffic from physical machines and VMs on a separate
VM host from the receiving machine.
2021-10-16 16:12:15 -05:00
Dustin ce0dac983f pyrocufflink: Set root password and SSH keys
1. Set a password for *root* on all machines (useful for logging in via
   serial console if network is down)
2. Set an authorized SSH key for root on all machines:

   * For Fedora 34, use my FIDO2 security token key
   * For all other hosts, use my ED25519 key
2021-10-16 15:40:20 -05:00
Dustin d6fff04985 r/base: Set SSH authorized keys for root
To ensure all machines have the same keys to allow root to log in via
SSH (in case Active Directory is unavailable or something).
2021-10-16 15:39:19 -05:00
Dustin 815240983f r/base: Set root password
The *base* role will now set the password for the *root* user, if the
`root_password_hash` variable is defined.  This ensures that there is a
way to log into machines directly, even if other authentication
mechanisms like Active Directory are unavailable.
2021-10-16 15:20:49 -05:00
Dustin 00d30a67fb base: Enable serial console on KVM VMs
Occasionally, VMs running on the main libvirt VM hosts will freeze or
otherwise become unavailable via network.  Sometimes, when this happens,
their normal consoles are unresponsive as well.  Having the serial
console available as a fallback can sometimes be helpful in recovering
from such situations.

To ensure the serial console is available on all VMs, we use a "dynamic"
group, based on the virtualization type and role of the managed node.
All KVM-based virtual machines are included in a group named *kvm-vm*.
A play in `base.yml` applies the *serial-console* role to members of
this group.
2021-10-16 14:34:51 -05:00
Dustin 8b91265ffe r/serial-console: Enable getty on serial console
The *serial-console* Ansible role enables and starts a systemd service
unit to activate a console getty on the specified serial console device
(by default: ttyS0).  This is particularly useful for virtual machines,
allowing one to control them in absence of a graphical VM management
tool.
2021-10-16 14:34:51 -05:00
Dustin c861d2f70a ci: homeassistant: Remove hassdb playbook
The `hassdb.yml` playbook is no longer used; the new Home Assistant
deployment uses the built-in database again, since it is stored on NVMe
instead of an SD card.

Further, the current deployment is hosted by a machine with a single
filesystem, which thus cannot be remounted read-only after applying
policy.
2021-10-16 10:20:01 -05:00
Dustin 347b5578c3 ci: lib: Skip remount if empty limit pattern
Some playbooks apply only to hosts that do not have read-only root
filesystems.  For these, the `rw_limit` pattern will be empty.  The
*Remount R/W* and *Remount R/O* stages should be skipped when this is
the case.
2021-10-16 10:17:34 -05:00
Dustin f8f19405c7 vm-hosts: Add camera virtual network
The *camera* virtual network is needed for VMs (i.e. *nvr0*) to connect
directly to security cameras.
2021-10-10 16:09:15 -05:00
Dustin 4d5076ced9 vm-hosts: Remove hass VM network
There are no longer any virtual machines connected to the Home Assistant
network.  Home Assistant runs on a physical machine.
2021-10-10 16:09:15 -05:00
Dustin 3be9c40f2b r/vmhost: Install mount helpers
Filesystems like NFS and CIFS require "helper" utilities (i.e.
`mount.nfs` and `mount.cifs`, respectively).  These need to be installed
in order for a system to be able to mount those filesystems.

The current shared storage system uses NFSv4, and as such, the
*nfs-utils* package needs to be installed on the VM hosts.
2021-10-10 16:09:15 -05:00
Dustin 9c97d0318c r/vmhost: mount shared filesystems
With the transition away from *dhcpcd* on the VM hosts, there is no
longer any need for a custom wait script that must run prior to
attempting to mount the shared filesystem.  This dramatically simplifies
the configuration necessary for shared storage.

I don't really see any reason why the shared storage configuration needs
to be managed by a separate role.  The *vmhost* role is not really
generic anyway, and will probably not work for any other VM host
deployment besides the two machines running now.  As such, I think it
makes sense to move the task to mount the shared filesystem into the
*vmhost* role and drop the *dch-storage-net* role.
2021-10-10 16:09:15 -05:00
Dustin dac34a3620 r/vmhost: Switch to pure YAML syntax 2021-10-10 16:09:15 -05:00
Dustin 3c8f26cf8d r/vmhost: Install libvirt network driver
The *libvirt-daemon-driver-network* package provides support for
managing virtual networks with libvirt.  It is necessary in order to use
managed networks in VM configuration, as opposed to directly specifying
VM network interfaces in their domain configuration.
2021-10-10 16:09:15 -05:00
Dustin 3f49175c1d host: vmhost0: Set host-specific network config
*vmhost0.pyrocufflink.blue* no longer uses `dhcpcd` for network
configuration, but *systemd-networkd*.

The host-specific network settings for a VM host include the
configuration for the management interface, as well as the configuration
of the physical ports that make up the bonded interfaces.
2021-10-10 16:09:15 -05:00
Dustin 55920c0025 vmhost: Define VM/storage networks
Originally, the network configuration for the VM networks and the
storage network was configured using the *netifaces* role.  This has
effectively stopped working in recent versions of Fedora, as it sort of
relied on `dhcpcd`, which has not been maintained in Fedora for a while
and no longer behaves correctly.  After evaluating *NetworkManager* as a
replacement, I decided that *systemd-networkd* is a more appropriate
solution.

There are effectively two "layers" of network configuration needed for
the VM hosts: the host-specific settings, and the common settings.  The
host-specific settings include such properties as the IP address of the
management interface and the names of the physical ports that make up
the bonded interfaces.  The common settings are the bonded interfaces,
the VLAN interfaces created on top of the bond, and the bridges that
provide access to VMs.

To configure the host-specific settings, each host simply needs the
appropriate `networkd_*` variables in its `host_vars` file.  For the
common settings, we apply the *systemd-networkd* role again in the
`vmhost.yml` with different values for these variables.  Thus,
effectively, `systemd-networkd.yml` manages the host-specific settings,
while `vmhost.yml` manages the common settings.
2021-10-10 16:09:15 -05:00
Dustin 2708dfe3f2 r/systemd-networkd: Role to configure networkd
*systemd-networkd* is (currently) my preferred way to manage network
interfaces on machines running Fedora.  The *systemd-networkd* role
provides a generic way to configure network links, devices, and
interfaces, using Ansible variables to generate network unit
configuration files.
2021-10-10 16:09:15 -05:00
Dustin cbcc0318f6 r/web/p-nextcloud: Set ProxyPreserveHost
The Internet-facing reverse proxy needs to pass the correct Host header
value in order for Nextcloud to correctly determine its own name.

https://github.com/nextcloud/desktop/issues/1284
2021-10-02 11:27:49 -05:00
Dustin 11357a9df3 hosts: Remove vpn0.p.b
The firewall provides both the Wireguard and IKEv2 VPN services.
2021-08-30 08:50:18 -05:00
Dustin d78005fac6 hosts: remove hass{1,db0}.p.b
*hass1.pyrocufflink.blue* and *hassdb0.pyrocufflink.blue* were part of
the old Home Assistant deployment.  Everything has been migrated to
*hass2.pyrocufflink.blue*, so these machines can be decommissioned now.
2021-08-24 20:03:59 -05:00
Dustin 9868873860 frigate: Enable RTMP on Back Yard camera
I couldn't get RTMP to work on the Back Yard camera because the `ffmpeg`
process kept crashing:

```
ffmpeg.back_yard.clips_rtmp    ERROR   : av_interleaved_write_frame(): Connection reset by peer
ffmpeg.back_yard.clips_rtmp    ERROR   : [flv @ 0x5562090c8ec0] Failed to update header with correct duration.
ffmpeg.back_yard.clips_rtmp    ERROR   : [flv @ 0x5562090c8ec0] Failed to update header with correct filesize.
ffmpeg.back_yard.clips_rtmp    ERROR   : Error writing trailer of rtmp://127.0.0.1/live/back_yard: Connection reset by peer
watchdog.back_yard             INFO    : Terminating the existing ffmpeg process...
watchdog.back_yard             INFO    : Waiting for ffmpeg to exit gracefully...
```

I thought increasing the value of `--shm-size` argument for `podman`
would help, but even going as high as 1024 mebibytes did not resolve the
problem.

Ultimately, I decided that it is not really necessary to view the full
4k stream in real time.  The back yard camera supports three streams, so
I set them all up for different roles.  I briefly considered using a
single 1080p stream for both object detection and RTMP streaming, but
this consumed considerable CPU time, so I decided against it for now.  I
may re-evaluate that option if I decide to purchase a TPU.
2021-08-22 20:31:59 -05:00
Dustin 544810ad34 home-assistant: Omit overlayfs from collectd
Podman containers create a *lot* of overlay filesystems.  There is no
reason to report these with collectd.
2021-08-22 11:38:40 -05:00
Dustin 58832b392b collectd: Add collectd_df variable
The `collectd_df` variable can be used to configure the *df* plugin for
collectd.  It should contain a map on key-value pairs that correspond
exactly to the plugin's configuration options.
2021-08-22 11:38:40 -05:00
Dustin c1a7105d09 hosts: Add hass2.p.b to rw-root
*hass2.pyrocufflink.blue* only has a single filesystem, stored on its
NVMe disk.
2021-08-22 10:15:10 -05:00
Dustin c4cd9f13f5 hosts: Remove build1-aarch64.p.b
This machine keeps crashing.  It's mostly unused for now anyway.  I'll
probably eventually replace it with a Raspberry Pi 4.
2021-08-22 09:54:18 -05:00
Dustin 4301391a79 hosts: Remove zezere0, motion0
Didn't end up needing Zezere, as I gave up on Fedora IoT.

No longer using motionEye since switching to Frigate.
2021-08-21 17:32:49 -05:00
Dustin b7ba6a59ab hosts: Add nvr0.p.b
*nvr0.pyrocufflink.blue* hosts Frigate.  It is deployed on a separate
subnet, for two reasons:

* To avoid streaming video from the cameras through the firewall
* To prevent any hosts on the LAN except Home Assistant from
  communicating with Frigate, since it does not have any kind of
  authentication or access control
2021-08-21 17:20:19 -05:00