Commit Graph

761 Commits (7c6ed667be1b734fe1192291185d2675c39005e3)

Author SHA1 Message Date
Dustin a4cc9d0c46 metricspi: Scrape tabitha.biz 2023-04-23 20:03:43 -05:00
Dustin 2920c25a69 websites/p-bitwarden: Redirect .blue to .net
Avoid confusion with WebAuthn by ensuring users only access the
application by its canonical name.
2023-04-23 18:45:28 -05:00
Dustin 6c68126a3a grafana: Update LDAP server host name
*dc0.p.b* has been gone for a while now.  All the current domain
controllers use LDAPS certificates signed by Let's Encrypt and include
the *pyrocufflink.blue* name, so we can now use the apex domain A record
to connect to the directory.
2023-04-12 14:07:51 -05:00
Dustin 78f65355fa gitea: Back up with BURP 2023-04-12 14:07:51 -05:00
Dustin 1da4c17a8c alerts: Add alerts for HTTPS certificates
These alerts will generate notifications when websites' HTTPS
certificates are not properly renewed automatically and become in danger
of expiring.
2023-04-12 13:55:31 -05:00
Dustin bf4133652c metrics: Scrape Jenkins with blackbox exporter
This is mostly to monitor the HTTPS certificate expiration.
2023-04-12 13:55:31 -05:00
Dustin dc2a05dc8f alerts: Add alert for BURP RAID array swap
This alert counts how long its been since the number of "active" disks
in the RAID array on the BURP server has changed.  The assumption is
that the number will typically be `1`, but it will be `2` when the
second disk synchronized before the swap occurs.
2023-04-11 22:25:36 -05:00
Dustin 2394bf7436 metricspi: Fix vmalert links
1. Grafana 8 changed the format of the query string parameters for the
   Explore page.
2. vmalert no longer needs the http.pathPrefix argument when behind a
   reverse proxy, rather it uses the request path like the other
   Victoria Metrics components.
2023-04-11 21:46:43 -05:00
Dustin 6c562c9821 alerts: Ignore missing mdraid disk for BURP
The way I am handling swapping out the BURP disk now is by using the
Linux MD RAID driver to manage a RAID 1 mirror array.  The array
normally operates with one disk missing, as it is in the fireproof safe.
When it is time to swap the disks, I reattach the offline disk, let the
array resync, then disconnect and store the other disk.

This works considerably better than the previous method, as it does not
require BURP or the NFS server to be offline during the synchronization.
2023-04-11 20:08:07 -05:00
Dustin 9921b2fd5e burp1.p.b: Set collectd SELinux domain permissive
Using the *md* plugin generates AVC denials like this:

	type=AVC msg=audit(1681259123.636:338441): avc:  denied  { read } for  pid=1438759 comm="collectd" name="md1" dev="devtmpfs" ino=646 scontext=system_u:system_r:collectd_t:s0 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file permissive=0
2023-04-11 19:26:25 -05:00
Dustin f16c2fae2f burp1.p.b: Enable md and thermal collectd plugins
The BURP storage volume is now backed by a Linux MD RAID array, so we
want to monitor its state.  Furthermore, since this machine is a
physical device, we should monitor its thermal characteristics as well.
2023-04-11 10:14:18 -05:00
Dustin a59f24a8b5 metricspi: Stop scraping speedtest
Running the speed test periodically was just wasting bandwidth.  It
failed frequently, and generally did not provide useful information.
2023-04-02 11:05:16 -05:00
Dustin 94de5d6067 samba-dc: Decrease Samba log level
The default log level (3) produces too much output and quickly fills the
`/var/log` volume on the domain controllers.
2023-03-08 11:26:57 -06:00
Dustin 748c432334 vaultwarden: Change Domain URL
The rule is "if it is accessible on the Internet, its name ends in .net"

Although Vaultwarden can be accessed by either name, the one specified
in the Domain URL setting is the only one that works for WebAuthn.
2023-03-03 11:17:07 -06:00
Dustin 45148421b0 smtp1.p.b: Allow SMTP relay from Kubernetes network
Applications running on the Kubernetes cluster need to be able to send
e-mail via the relay.
2023-01-13 19:36:20 -06:00
Dustin b1fa4fc8a7 r/web/chmod777.sh: Add HTTP redirect
The HTTP->HTTPS redirect for chmod777.sh was only working by
coincidence.  It needs its own virtual host to ensure it works
irrespective of how other websites are configured.
2023-01-09 13:06:56 -06:00
Dustin 1b7a8885b8 r/web/hlc: Configure formsubmit
Tabitha's Hatch Learning Center site has two user submission forms: one
for signing in/out students for class, and another for parents to
register new students for the program.  These are handled by
*formsubmit* and store data in CSV spreadsheets.
2023-01-09 12:59:58 -06:00
Dustin 632e1dd906 metricspi: Update LDAP configuration
All domain controllers now use the Let's Encrypt wildcard certificate
for the *pyrocufflink.blue* domain.  Further, *dc2.p.b* is
decommissioned.
2023-01-09 12:23:54 -06:00
Dustin 90f9e5eba5 samba-dc: Manage sudoers
Domain controllers only allow users in the *Domain Admins* AD group to
use `sudo` by default.  *dustin* and *jenkins* need to be able to apply
configuration policy to these machines, but they are not members of said
group.
2022-12-23 08:47:31 -06:00
Dustin bc4c7edbad r/base: Clear facts after installing python-selinux
If the Python bindings for SELinux policy management are not installed
when Ansible gathers host facts, no SELinux-related facts will be set.
Thus, any tasks that are conditional based on these facts will not run.
Typically, such tasks are required for SELinux-enabled hosts, but must
not be performed for non-SELinux hosts.  If they are not run when they
should, the deployment may fail or applications may experience issues at
runtime.

To avoid these potential issues, the *base* role now forces Ansible to
gather facts again if it installed the Python SELinux bindings.

Note: one might suggest using `meta: clear_facts` instead of `setup` and
letting Ansible decide if and when to gather facts again. Unfortunately,
this for some reason doesn't work; the `clear_facts` meta task just
causes Ansible to crash with a "shared connection to {host} closed."
2022-12-23 08:44:30 -06:00
Dustin 9408ee31c3 home-assistant: Back up Zigbee/ZWave/Mosquitto
Mosquitto, Zigbee2MQTT, and ZWaveJS2MQTT all have persistent state that
needs to be backed up in addition to Home Assistant's own data.
2022-12-23 06:56:52 -06:00
Dustin 6b4b18dac8 facts: Add PB to force fetching facts
Some playbooks/roles require facts from machines other than the target.
The `facts.yml` playbook can be used to gather facts from machines
without running any other tasks.
2022-12-23 06:56:52 -06:00
Dustin 10344b07c7 hosts: Add ag62kz.p.b
New domain controller (Fedora 37): *ag62kz.pyrocufflink.blue*
2022-12-23 06:56:52 -06:00
Dustin 8e1c67f591 hosts: Remove dc2
*dc2.pyrocufflink.blue* has been decommissioned.
2022-12-23 06:56:52 -06:00
Dustin f0a70c70e5 samba-dc: Install dch-selinux
The *dch-selinux* package contains a SELinux policy module for Samba AD
DC.  This policy defines a `samba_t` domain for the `samba` process.
While the domain is (currently) unconfined, it is necessary in order to
provide a domain transition rule for `winbindd`.  Without this rule,
`winbindd` would run in `unconfined_service_t`, which causes its IPC
pipe files to be incorrectly labelled, preventing other confined
services like `sshd` from accessing them.
2022-12-23 06:54:28 -06:00
Dustin 4bc587e408 r/dch-selinux: Install dch-selinux package
The *dch-selinux* package contains customized SELinux policy modules.
I haven't worked out exactly how to build an publish it through a
continuous integration pipeline yet, so for now it's just hosted in my
user `public_html` folder on the main file server.
2022-12-23 06:52:28 -06:00
Dustin 5661910a21 samba-dc: Add sysvolsync script
Samba AD DC does not implement [DFS-R for replication of the SYSVOL][0]
contents.  This does not make much of a difference to me, since
the SYSVOL is really only used for Group Policy.  Windows machines may
log an error if they cannot access the (basically empty) GPO files, but
that's pretty much the only effect if the SYSVOL is in sync between
domain controllers.

Unfortunately, there is one side-effect of the missing DFS-R
functionality that does matter.  On domain controllers, all user,
computer, and group accounts need to have Unix UID/GID numbers mapped.
This is different than regular member machines, which only need UID/GID
numbers for users that will/are allowed to log into them.  LDAP entries
only have ID numbers mapped for the latter class of users, which does
not include machine accounts.  As a result, Samba falls back to
generating local ID numbers for the rest of the accounts.  Those ID
numbers are stored in a local database file,
`/var/lib/samba/private/idmap.ldb`.  It would seem that it wouldn't
actually matter if accounts have different ID numbers on different
domain controllers, but there are evidently [situations][1] where DCs
refuse to allocate ID numbers at all, which can cause authentication to
fail.  As such, the `idmap.ldb` file needs to be kept in sync.

If we're going to go through the effort of synchronizing `idmap.ldb`, we
might as well keep the SYSVOL in sync as well.  To that end, I've
written a script to synchronize both the SYSVOL contents and the
`idmap.ldb` file.  It performs a simple one-way synchronization using
`rsync` from the DC with the PDC emulator role, as discovered using DNS
SRV records.  To ensure the `idmap.ldb` file is in a consistent state,
it only copies the most recent backup file.  If the copied file differs
from the local one, the script stops Samba and restores the local
database from the backup.  It then flushes Samba's caches and restarts
the service.  Finally, it fixes the NT ACLs on the contents of the
SYSVOL.

Since the contents of the SYSVOL are owned by root, naturally the
synchronization process has to run as root as well.  To attempt to limit
the scope of control this would give the process, we use as much of the
systemd sandbox capabilities as possible.  Further, the SSH key pairs
the DCs use to authenticate to one another are restricted to only
running rsync.  As such, the `sysvolsync` script itself cannot run
`tdbbackup` to back up `idmap.ldb`.  To handle that, I've created a
systemd service and corresponding timer unit to run `tdbbackup`
periodically.

I considered for a long time how to best implement this process, and
although I chose this naïve implementation, I am not exactly happy with
it.  Since I do not fully understand *why* keeping
the `idmap.ldb` file in sync is necessary, there are undoubtedly cases
where blindly copying it from the PDC emulator is not correct.  There
are definitely cases where the contents of the SYSVOL can be updated on
a DC besides the PDC emulator, but again, we should not run into them
because we don't really use the SYSVOL at all.  In the end, I think this
solution is good enough for our needs, without being so complicated

[0]: https://wiki.samba.org/index.php?title=SysVol_replication_(DFS-R)&oldid=18120
[1]: https://lists.samba.org/archive/samba/2021-November/238370.html
2022-12-22 18:55:07 -06:00
Dustin 77191c8b5a Fedora37: Set collectd SELinux domain permissive
*collectd* is broken by default on Fedora 36 and 36.  Several plugins
generate AVC denials.
2022-12-19 10:22:00 -06:00
Dustin 019276da88 collect: Import dyngroups.yml playbook
We need to import the `dyngroups.yml` playbook so that the dynamic host
groups are populated.  Without this, the *RedHat* group is empty, so the
*collectd-version* role is never applied.
2022-12-19 10:20:57 -06:00
Dustin 4a1e961d57 dyngroups: Also group by distribution and version
Adding dynamic groups for speciffic Linux distributions and versions
thereof so we can apply settings based on those properties.
2022-12-19 10:20:09 -06:00
Dustin 3cc501abef collect: Restart after changing SELinux permissive
*collectd* needs to be restarted after changing its SELinux domain
to/from permissive, as many operations that may fail only happen at
startup.
2022-12-19 10:19:08 -06:00
Dustin 3949a40f64 r/collectd-version: Fix handlers
Upating the `collect-version` script should restart the
*collectd-version* service, not *collectd* itself.
2022-12-19 10:17:57 -06:00
Dustin 637289036a blackbox: Update pyrocufflink DNS check
I changed the naming convention for domain controller machines.  They
are no longer "numbered," since the plan is to rotate through them
quickly.  For each release of Fedora, we'll create two new domain
controllers, replacing the existing ones.  Their names are now randomly
generated and contain letters and numbers, so the Blackbox Exporter
check for DNS records needs to account for this.
2022-12-19 09:04:37 -06:00
Dustin 066a68318c hosts: Add dc-4k6s8e.p.b
This is a new domain controller running Fedora 37.
2022-12-18 22:49:44 -06:00
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