Commit Graph

528 Commits (319cc80a9fdcc846b5b53e75b18254da37949d83)

Author SHA1 Message Date
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 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 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 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 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
Dustin ee0e6873ad r/collectd-sensors: Install collectd sensors plugin
The *sensors* plugin for collectd reads temperature information from the
I²C/SMBus using *lm_sensors*.  Naturally, it is only useful on physical
machines, so it is not installed or enabled by default.
2022-07-21 13:14:25 -05:00
Dustin a60327a995 r/collectd: Allow the thermal plugin
Raspberry Pi devices provide SoC temperature information through thermal
zone data in sysfs.
2022-07-21 12:37:07 -05:00
Dustin 29a6a0540f r/collectd: Better control over enabled plugins
Instead of a simple list of disabled plugins, hosts and host groups can
now control whether plugins are enabled or disabled using the
`collectd_plugins` map.  The map keys are plugin names, and the values
are booleans indicating if the plugin is enabled.

Using this mechanism, some plugins can be disabled by default (e.g. the
*md* plugin), and enabling them per host or per host group is simpler.
2022-07-21 12:22:19 -05:00
Dustin c7ca8e5b15 r/collectd: Allow enabling the md plugin
The *md* plugin monitors Linux multi-disk RAID (*mdraid*) devices.
2022-07-21 12:22:19 -05:00
Dustin e7534d36cf r/mosquitto: Support persistence
Mosquitto can save retained messages, persistent clients, etc. to the
filesystem and restore them at startup.  This allows state to be
maintained even after the process restarts.
2022-05-29 11:25:25 -05:00
Dustin 24228953b0 r/samba-dc: Configure logrotate for KDC
The KDC service, as managed by Samba, continuously logs to two files
that need to be rotated.  The upstream configuration for logrotate only
manages one of these files, and does not correctly signal the service
after rotating, as it expects the service to be managed by systemd
instead of Samba.  As such, we need to adjust the configuration to
handle both files and send SIGHUP directly to the process.
2022-04-24 11:37:13 -05:00
Dustin d363026db2 websites: dustin.hatch.name: Deploy new site
Promoting the new site I have been working on at *dustin.hatch.is* to my
main domain, *dustin.hatch.name*.  The new site is just static content,
generated and uploaded by a Jenkins job.

Finally have a certificate for *dustin.hatch.name* now, too!
2022-04-23 15:30:40 -05:00
Dustin 3c8e576841 grafana: Enable anonymous access
Allow unauthenticated users to view dashboards.  Useful for Heads-Up
Displays.
2022-03-07 20:10:13 -06:00
Dustin 5e2cfee8a1 r/protonvpn: watchdog: Improve error handling
This resolves two issues with fetching the Proton VPNserver list:

1. If a connection error occurs when fetching the list, it will be
   ignored, just as with HTTP errors
2. If any errors are encountered when fetching the list, and a valid
   cache was loaded, its contents are returned, regardless of the
   timestamp of the cache file.
2022-03-01 21:28:21 -06:00
Dustin 5485fc6f93 websites/d…and…t: Configure formsubmit
To handle the RSVP form on *dustinandtabitha.com*, we are going to use
*formsubmit*.  It runs on the same machine that hosts the website, so
there's no dealing with CORS.  The */submit/rsvp* path, which is proxied
to the backend, is the RSVP form's target.
2022-02-27 17:56:54 -06:00
Dustin b350698148 r/formsubmit: Deploy formsubmit app
*formsubmit* is a simple, customizable HTML for submission handler.  I
designed it for Tabitha to use to collect information from forms on her
websites.  Notably, we will use it for the RSVP page on our wedding
invitation site.
2022-02-27 17:42:15 -06:00
Dustin 3632698f37 websites/dustinandtabitha.com: Add role
Wedding website 😍
2022-02-27 17:41:40 -06:00
Dustin 5efbee725e home-assistant: Omit history DB from backups
The state history database is entirely too big.  It takes over an hour
to create a backup of it, which usually causes BURP to time out.  The
data it stores isn't particularly interesting anyway.  Instead of trying
to back it up and ultimately not getting any backup at all, we'll just
skip it altogether to ensure we have a consistent backup of everything
else that is actually important.
2022-01-02 12:07:12 -06:00
Dustin d8bb629c5d r/frigate: Ensure service starts at boot
Missing a task to enable the *frigate.service* unit meant that the
service would not start automatically when the machine booted.
2021-12-30 09:35:14 -06:00
Dustin dfa61c8a73 r/nextcloud: Increase Apache timeout
Uploading large files can take a very long time.  If the process takes
longer than the configured timeout in Apache, it will be aborted and the
client will receive an HTTP 504 Gateway Timeout error.  Increasing the
timeout will help alleviate this for files up to a certain size.
Notably, it now lets me upload Signal backups without errors.
2021-12-22 11:28:52 -06:00
Dustin 7d7dda6061 r/nextcloud: Dynamically set version in config
Nextcloud thinks it needs to run the upgrade/migration tool if the
version number in its configuration file does not match the running
version.  It then updates the config file with the correct version. The
next time the configuration policy is applied, however, the version will
revert back to whatever is set in the template.  This will re-trigger
the upgrade notification.

To avoid this problem, we now set the version in the configuration file
dynamically.  Nextcloud writes its version number in a constant in
`version.php`.
2021-12-20 22:18:14 -06:00
Dustin 7ab3787798 r/nextcloud: Correct memcache config syntax
Nextcloud uses double backslashes in its fully-qualified path names.
Although single backslashes work, the application will replace them,
leading to a constant conflict between itself and the Ansible template.
2021-12-20 22:15:53 -06:00
Dustin e55fc8f5af r/homeassistant et al.: Increase start timeout
The first time launching a container after pulling a new image, it can
take several minutes for the container to actually start.  Podman has to
set up the overlay filesystems, which is very slow on a Raspberry Pi.

With the default start timeout, systemd may end up killing the process
before the container is completely set up.  Thus, we need to increase
the timeout to ensure there is plenty of time for Podman to work.
2021-12-20 09:59:14 -06:00
Dustin f8e3bdade0 r/z*2mqtt: Fix device node contexts at start
Processes running in containers only have access to a limited set of
devices, based on their SELinux type label.  The USB serial devices
exposed by the Zwave and Zigbee adapters are not labelled correctly by
default to allow them to be used in containers.

Using `chcon` to change the type label of the device before starting the
container seems to work, but seems a bit kludgy.  It would probably be
better to use a SELinux file context rule and/or a udev rule to ensure
the label is set correctly when the device node is created.
2021-12-18 16:45:53 -06:00
Dustin 6f9ff86788 r/homeassistant: Wait for network to start
Although Home Assistant itself will start fine if the network is not yet
available, some integrations will not.  Notably, the Matrix integration
will fail to load if it cannot contact the homeserver when it is first
initialized.  To avoid this problem, we can just delay starting Home
Assistant until the network is available.
2021-12-18 16:45:53 -06:00
Dustin 1f9e13a33b r/z*2mqtt: Wait for network before starting
The Zigbee2MQTT and ZWaveJS2MQTT servers do not start correctly if the
network is not yet available.
2021-12-18 16:45:52 -06:00
Dustin 739ffb2845 home-assistant: Configure BURP backups
Take a snapshot of the history database first, then back up everything
in `/var/lib/homeassistant`.
2021-12-17 20:57:38 -06:00
Dustin fdfdaa6fe6 bitwarden_rs: Update burp backup path
Vaultwarden data are stored in a different location since the migration
to Podman.
2021-12-17 20:33:31 -06:00
Dustin 80b267d6e5 r/burp: Enable progress counter for ad-hoc runs
Before the `burp` tool gained the `-Q` option, the only way to disable
the progress counter was through the configuration file.  Since we do
not want any output from automatic backups (except of course
catastrophic failures), since it would end up being e-mailed by cron,
the progress counter had to be disabled globally.  This meant that
on-demand runs on a terminal could not have a progress counter, which
was pretty disappointing.

Now that `burp` has `-Q`, this is no longer the case.  Scheduled backups
can run with `-Q`, but ad-hoc runs can omit it to get a progress
counter.
2021-12-17 20:19:30 -06:00
Dustin 948079dafa r/samba-dc: Configure samba logging
Send logs to the systemd journal for easier viewing and disable logging
to a file.  Also, the `samba_dc_log_level` variable can control the log
level (0-10, 0 being off, 10 being insane debugging).
2021-11-07 16:18:51 -06:00
Dustin e3b5b4d5ff r/bitwarden_rs: Migrate to podman
Docker is effectively deprecated by Fedora/Red Hat.  It is a pain in the
ass to work with anyway.  Podman integrates better with systemd, and is
in general more aligned with how I prefer to deploy and manage
applications.

I am following the same pattern here that I have used for Home
Assistant, ZWaveJS2MQTT, etc.  The systemd service starts the container
with `podman`, passing the necessary arguments for UID/GID mapping, etc.
Note that, by default, Vaultwarden expects to be able to bind to port
80; since the container is unprivileged, we have to configure it (or
rather, its embedded HTTP server [Rocket](https://rocket.rs)) to listen
on a different port.  We also configure it to listen only on the
loopback, since it is being proxied by Apache to the outside network.

To migrate the data from the Docker volume, we just have to copy the
files and fix their ownership.

The *bitwarden_rs* project was recently renamed to *Vaultwarden*, so I
took this opportunity to update the name in most places within the
*bitwarden_rs* role.
2021-11-06 19:33:33 -05:00
Dustin d39b2bcb19 r/winbind: Add domain-join tag
Sometimes I need to configure a machine to be a domain member without
actually adding it to the domain.  Now I can by running
`ansible-playbook` with `--skip-tags domain-join`
2021-11-06 18:12:29 -05:00
Dustin 3f9b8c1d9b r/vmhost: Install libvirt storage driver
The *libvirt-daemon-driver-storage-core* package provides the libvirt
plugin needed for storage management, e.g. `virsh blockresize`.
2021-11-06 18:10:32 -05:00
Dustin 7bb1eb677e r/samba-dc: Use rfc2307 on all DCs
I honestly don't remember why the `use rfc2307` setting was only enabled
on the first DC.  All DCs seem to need this setting in order to use the
UID/GID numbers from the directory, instead of using auto-generated
numbers.
2021-10-31 21:07:49 -05:00
Dustin 803fd5ef2a r/systemd-networkd: Enable and start the service
Obviously, the *systemd-networkd* service needs to be running in order
for it to manage the network connections.
2021-10-31 14:29:30 -05:00
Dustin ff7c58ae71 r/collectd-nut: Configure nut plugin for collectd
The *nut* plugin for *collectd* fetches data from Network UPS Tools.
This is useful for monitoring UPS statistics over time.
2021-10-31 14:26:26 -05:00
Dustin 4beade5465 r/nut: Add role for Network UPS Tools
The *nut* role installs and configures Network UPS Tools.
2021-10-31 14:25:59 -05:00
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 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 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 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 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 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 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 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 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 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 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 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 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
Dustin 997760968e r/frigate: Add role to deploy Frigate
Frigate is an NVR that uses machine learning to detect objects on camera
in real time.  It integrates with Home Assistant to expose sensors which
can be used for automation, etc.

The only official way to deploy Frigate is with a container, so we use
Podman and systemd to manage it.
2021-08-21 17:16:58 -05:00
Dustin 7d2b3887c2 Add ability to update HA-related containers
Home Assistant, Zigbee2MQTT, and ZWaveJS2MQTT can now be updated by
setting the corresponding Ansible variable.
2021-08-12 19:02:34 -05:00
Dustin 8f6f553820 Add HTTPS certificate for hass2.p.b 2021-07-24 18:39:45 -05:00
Dustin d78257326a Merge branch 'tabitha-website' 2021-07-24 18:37:05 -05:00
Dustin 910d430e1e website: Deploy Tabitha's website
Tabihta's website is a very simple, static HTML site.  It uploaded via
SFTP and served at *tabitha.biz*.
2021-07-24 18:36:13 -05:00
Dustin 5d7ebbaa05 r/hass-dhcp: Clean up DHCP/DNS service
The production deployment of *dnsmasq* for Home Assistant has deviated
from how the *hass-dhcp* role configures it.  Bringing the role back in
sync with how things really are.
2021-07-24 18:33:15 -05:00
Dustin ceeb61cdb0 roles/homeassistant: Proxy ZwaveJS2Mqtt Web UI
ZwaveJS2Mqtt includes a very powerful web-based UI for configuring and
controlling the Z-Wave network.  This functionality is no longer
available within Home Assistant itself, so being able to access the
ZwaveJS2Mqtt UI is crucial to operating the network.

I wanted to make the UI available at */zwave/*, which requires using
*mod_rewrite* to conditionally proxy requests based on the `Connection`
HTTP header, since the UI passes both HTTP and WebSocket requests to the
same paths.  *mod_rewrite* configuration is not inherited from the main
server configuration to virtual hosts, so the
`RewriteRule`/`RewriteCond` directives have to be specified within the
`<VirtualHost>` block.  This means that the Home Assistant proxy
configuration has to be within its own virtual host, and the
Zwavejs2Mqtt configuration has to be there as well.
2021-07-19 15:58:58 -05:00
Dustin b826d8355e hosts: Add hass2.p.b
*hass2.pyrocufflink.blue* is a Raspberry Pi Compute Module 4-based
system, currently mounted in a WaveShare CM4 Mini Base Board (A).  With
an NVMe SSD for primary storage, it runs significantly faster than a
standard Raspberry Pi 4, and blows the old Raspberry Pi 3-based Home
Assistant deployment out of the water. It has a Zooz 700 series Z-Wave
Plus S2 USB stick and a ConBee II Zigbee USB stick attached to its USB
2.0 ports.  It runs a customized Fedora Minimal distribution.
2021-07-19 15:58:58 -05:00
Dustin 2f3d0f74a1 roles/Zigbee2MQTT: Deploy using Podman
Zigbee2MQTT is very similar to ZwaveJS2Mqtt: it is a daemon process that
communicates with the Zigbee radio and integrates with Home Assistant
using MQTT.  Naturally, I decided to deploy it in the same way as
ZwaveJS2Mqtt, using a systemd unit to run it in a container with Podman.
2021-07-19 15:58:58 -05:00
Dustin 57b3039f2c roles/mosquitto: Update for Mosquitto 2.x
Mosquitto 2.x included two significant changes from 1.6:

* There is no longer a "default" listener; all listeners are configured
  in the same way
* The daemon drops privileges *before* reading TLS certificates and
  private keys
2021-07-19 15:58:58 -05:00
Dustin 0f70a5b6ba roles/zwavejs2mqtt: Deploy Z2M using Podman
Home Assistant no longer recommends using the built-in libopenzwave
integration for communicating with Z-Wave devices.  Evidently, OpenZWave
is no longer maintained, and community efforts have shifted toward
Z-Wave JS.

Z-Wave JS is architecturally much different than the legacy Z-Wave
integration.  Instead of running the network controller inside the Home
Assistant process, a separate daemon communicates with the Z-Wave radio.
Home Assistant integrates with that daemon using a WebSockets API.  This
has the advantage of decoupling the network operation from the lifecycle
of the Home Assistant process: restarting Home Assistant (e.g. to load
new configuration changes) does not take the Z-Wave network offline.

ZwaveJS2Mqtt is a distribution of the Z-Wave JS daemon, as well as a
web-based user interface for configuring it.  Although its name implies
that it uses MQTT for communication, this feature is actually optional,
and the native WebSockets API can still be used for integration with
Home Assistant.

I decided to follow the same deployment pattern for ZwaveJS2Mqtt as for
Home Assistant itself: run the application from a container image using
Podman.  This of course simplifies the installation of the application
significantly, leaving most of that work up to the maintainer of the
container image.  Podman provides the container runtime, managing the
privileges, etc.  The systemd service unit starts Podman, configuring an
ephemeral container on each run.  The container uses the default network
namespace, avoiding the unnecessary overhead of port mapping.  It uses
Podman's "rootless" mode, via the `--uidmap` and `--gidmap` arguments,
mapping users inside the container, including root, to unprivileged
users on the host.  The Z-Wave radio, which is specified by the
`zwavejs_device` Ansible variable,  is passed into the container via the
`--device` argument.
2021-07-19 15:58:52 -05:00
Dustin 288b050a33 roles/homeassistant: Deploy container with Podman
Installing Home Assistant in a Python virtualenv is rather tedious,
especially on non-x86 machines.  The main issue is Python packages that
include native extensions, as many of these do not have binary wheels
available for aarch64, etc. on PyPI.  Thus, to install these, they have
to be built from source, which then requires the appropriate development
packages to be installed.  Additionally, compiling native code on a
Raspberry Pi is excruciatingly slow.  I have considered various ways of
mitigating this, but all would require a substantial time investment,
both up front and ongoing, making them rather pointless.  Eventually, I
settled on just deploying the official Home Assistant container image
with Podman.

Although Podman includes a tool for generating systemd service unit
files for running containers, I ended up creating my own for several
reasons.  First and foremost, the generated unit files configure the
containers to run as *root*, but I wanted to run Home Assistant as an
unprivileged user.  Unfortunately, I could not seem to get the container
to work when dropping privileges using the `User` directive of the unit.
Fortunately, `podman` has `--uidmap` and `--gidmap` arguments, which I
was able to use to map UID/GID 0 in the container to the *homeassistant*
user on the host.  Another drawback of the generated unit files is that
they specify a "forking" type service, which is not really necessary.
Podman/conmon supports the systemd notify protocol, but the generator
has not been updated to make use of that yet.

Recent versions of Home Assistant are more strict with respect to how
reverse proxies are handled.  In order to use one, it must be explicitly
listed in the configuration file.  Therefore, the *homeassistant*
Ansible role will now create a stub `configuration.yaml`, based on the
one generated by Home Assistant itslf when it starts for the first time
on a new machine, that includes the appropriate configuration for a
reverse proxy running on the same machine.  The stub configuration will
not overwrite an existing configuration file, so it is only useful when
deploying Home Assistant for the first time on a new machine.

Overall, although I think a 300+ MB container image is ridiculous,
deploying Home Assistant this way should make it a lot easier to manage,
especially when updating.
2021-07-19 13:38:08 -05:00
Dustin 4aa3cdddd9 hosts: Add zezere0.p.b
*zezere0.pyrocufflink.blue* hosts the local deployment of the Fedora
Zezere provisioning service.
2021-07-05 09:34:25 -05:00
Dustin ccdaad40bf zezere: role/playbook to deploy Zezere
Zezere is the Fedora IoT device provisioning service.  It is the
software that runs *provision.fedoraproject.org*, but it can be
self-hosted (if you can figure it out; there is no documentation
whatsoever).

The main use case for running Zezere locally is to automatically add
trusted SSH public keys to Fedora IoT devices, without depending on a
cloud service.  This playbook sets up Zezere with the very minimal
configuration needed to meet this goal.
2021-07-05 09:34:25 -05:00
Dustin 9565b740b0 hosts: add stats0.p.b
*stats0.pyrocufflink.blue* hosts Grafana (for now, adding Victoria
Metrics, etc. later)
2021-07-02 21:55:02 -05:00
Dustin 5e61e93cea roles/grafana: Deploy Grafana
This commit introduces the *grafana* role and the corresponding
`grafana.yml` playbook.  The role installs Grafana using the system
package manager, and configures the server (including LDAP
authentication).
2021-07-02 21:47:33 -05:00
Dustin 5de8f3e612 roles/nginx: Add role for nginx
This role installs nginx and provides a base/skeleton configuration
suitable for most deployments.
2021-06-29 21:00:46 -05:00
Dustin 1fcfc80254 r/protonvpn: watchdog: Also watch for EAP/FAIL
Occasionally, ProtonVPN servers randomly reject the EAP authentication
credentials.  When this happens, the tunnel fails and is not restarted
automatically by strongSwan.  As such, the watchdog needs to react to
this event as well.
2021-06-27 09:23:46 -05:00
Dustin 6b9b87a406 roles/nextcloud: Configure outbound email
Since the Nextcloud configuration file is managed by the configuration
policy, all of the settings configurable through the web UI need to be
templated.  One important group of settings is the outbound email
configuration.  This can now be configured using the `nextcloud_smtp`
Ansible variable.
2021-06-25 11:12:38 -05:00
Dustin c68f10d771 roles/nextcloud: Use Redis for caching
The Nextcloud community [recommends][0] using Redis as a cache provider,
to improve response times and file locking reliability.
2021-06-25 11:12:12 -05:00
Dustin 05a414100a roles/redis: Add role to deploy Redis
This simple role installs the *redis* package and starts the associated
service.  It leaves the configuration as provided by upstream, at least
for now.
2021-06-25 11:10:10 -05:00
Dustin b86e0d8f29 roles/nextcloud: Switch to Fedora package
Fedora now includes a packaged version of Nextcloud.  This will be
_much_ easier to maintain than the tarball-based distribution method.
There are some minor differences in how the Fedora package works,
compared to the upstream tarball.  Notably, it puts the configuration
file in `/etc/` and makes it read-only, and it stores persistent data
separate from the application.  These differences require modifications
to the Apache and PHP-FPM configuration, but the package also included
examples to make this easier.  Since the `config.php` is read-only now,
it has to be managed by the configuration policy; it cannot be modified
by the Administration web UI.
2021-06-24 20:21:48 -05:00
Dustin 0add34a9a3 roles/protonvpn: Add watchdog script
One major problem with the current DNS-over-VPN implementation is that
the ProtonVPN servers are prone to random outages.  When the server
we're using goes down, there is not a straightforward way to switch to
another one.  At first I tried creating a fake DNS zone with A records
for each ProtonVPN server, all for the same name.  This ultimately did
not work, but I am not sure I understand why.  strongSwan would
correctly resolve the name each time it tried to connect, and send IKE
initialization requests to a different address each time, but would
reject the responses from all except the first address it used.  The
only way to get it working again was to restart the daemon.

Since strongSwan is apparently not going to be able to handle this kind
of fallback on its own, I decided to write a script to do it externally.
Enter `protonvpn-watchdog.py`.  This script reads the syslog messages
from strongSwan (via the systemd journal, using `journalctl`'s JSON
output) and reacts when it receives the "giving up after X tries"
message.  This message indicates that strongSwan has lost connection to
the current server and has not been able to reestablish it within the
retry period.  When this happens, the script will consult the cached
list of ProtonVPN servers and find the next one available.  It keeps
track of the ones that have failed in the past, and will not connect to
them again, so as not to simply bounce back-and-forth between two
(possibly dead) servers.  Approximately every hour, it will attempt to
refresh the server list, to ensure that the most accurate server scores
and availability are known.
2021-06-21 20:48:23 -05:00
Dustin bb6186b90e roles/mosquitto: Add role to deploy MQTT server
*Mosquitto* implements an MQTT server.  It is the recommended
implementation for using MQTT with Home Assistant.

I have added this role to deploy Mosquitto on the Home Assistant server.
It will be used to send data from custom sensors, such as the
temperature/pressure/humidity sensor connected to the living room wall
display.
2021-05-02 19:10:17 -05:00
Dustin 7b04326146 roles/websites/chmod777: Remove HTTP vhost
Since there are no other plain HTTP virtual hosts, the one defined for
chmod777.sh became the "default."  Since it explicitly redirects all
requests to https://chmod777.sh, it caused all non-HTTPS requests to be
redirected there, regardless of the requested name.  This was
particularly confusing for Tabitha, as she frequently forgets to put
https://…, and would find herself at my stupid blog instead of
Nextcloud.
2021-03-11 19:57:37 -06:00
Dustin 6aaf1b7dbb roles/strongswan-swanctl: Load esp4 module at boot
The *esp4* kernel module does not load automatically on Fedora.  Without
this module, strongSwan can establish IKE SAs, but not ESP SAs.  Listing
the module name in a file in `/etc/modules-load.d` configures the
*systemd-modules-load* service to load it at boot.
2021-02-17 20:33:41 -06:00
Dustin 243510e74a roles/protonvpn: Fix swanctl syntax
I believe the reason the VPN was not auto-restarting was because I had
incorrectly specified the `keyingtries` and `dpd_delay` configuration options.
These are properties of the top-level connection, not the child. I must
have placed them in the `children` block by accident.
2021-02-09 07:17:32 -06:00
Dustin 81417068c2 roles/synapse: Add cert role dependency
The *cert* role must be defined as a role dependency now, so that the
role can define a handler to "listen" for the "certificate changed"
event.  This change happened on *master*, before the *matrix* branch was
merged.
2021-01-31 15:38:18 -06:00
Dustin 7f8a9ce114 roles/graylog: Update Graylog repository RPM URL
Graylog 3.3 is currently installed on logs0.  Attempting to install the
*graylog-3.1-repository* package causes a transaction conflict, making
the task and playbook fail.
2021-01-31 15:33:42 -06:00
Dustin ee93586a95 roles/apache: Add previously-ignored cert symlinks
Before the advent of `ansible-vault`, and  long before `certbot`/`lego`,
I used to keep certificate files (and especially private key files) out
of the Git repository.  Now that certificates are stored in a separate
repository, and only symlinks are stored in the configuration policy,
this no longer makes any sense.  In particular, it prevents the continuous
enforcement process from installing Let's Encrypt certificates that have
been automatically renewed.
2021-01-24 17:08:00 -06:00
Dustin 7d740079c8 roles/ssh-hostkeys: Remove duplicate keys for git0 2020-12-30 22:13:47 -06:00
Dustin 5a114eecf0 websites/proxy-matrix: Add Synapse rev proxy setup
The *websites/proxy-matrix* role configures the Internet-facing reverse
proxy to handle the *hatch.chat* domain.  Most Matrix communication
happens over the default HTTPS port, and as such will be directed
through the reverse proxy.
2020-12-30 22:05:26 -06:00
Dustin 2df1605421 hosts: Add matrix0.p.b
*matrix0.pyrocufflink.blue* hosts the Matrix homeserver for
*hatch.chat*.
2020-12-30 22:04:51 -06:00
Dustin 371305bed4 roles/synapse: Deploy the Matrix homeserver
The *synapse* role and the corresponding `synapse.yml` playbook deploy
Synapse, the reference Matrix homeserver implementation.

Deploying Synapse itself is fairly straightforward: it is packaged by
Fedora and therefore can simply be installed via `dnf` and started by
`systemd`.  Making the service available on the Internet, however, is
more involved.  The Matrix protocol mostly works over HTTPS on the
standard port (443), so a typical reverse proxy deployment is mostly
sufficient.  Some parts of the Matrix protocol, however, involve
communication over an alternate port (8448).  This could be handled by a
reverse proxy as well, but since it is a fairly unique port, it could
also be handled by NAT/port forwarding.  In order to support both
deployment scenarios (as well as the hypothetical scenario wherein the
Synapse machine is directly accessible from the Internet), the *synapse*
role supports specifying an optional `matrix_tls_cert` variable.  If
this variable is set, it should contain the path to a certificate file
on the Ansible control machine that will be used for the "direct"
connections (i.e. on port 8448).  If it is not set, the default Apache
certificate will be used for both virtual hosts.

Synapse has a pretty extensive configuration schema, but most of the
options are set to their default values by the *synapse* role.  Other
than substituting secret keys, the only exposed configuration option is
the LDAP authentication provider.
2020-12-30 21:54:02 -06:00
Dustin 2da26d9bf6 roles/bitwarden_rs: Ensure docker service runs
Since the *bitwarden_rs* relies on Docker for distribution and process
management (at least for now), it needs to ensure that the `docker`
service starts automatically.
2020-12-30 21:02:32 -06:00
Dustin f9e8c78e5a roles/websites: Set authorized_keys file perms
Because the various "webapp.*" users' home directories are under
`/srv/www`, the default SELinux context type is `httpd_sys_content_t`.
The SSH daemon is not allowed to read files with this label, so it
cannot load the contents of these users' `authorized_keys` files.  To
address this, we have to explicitly set the SELinux type to
`ssh_home_t`.
2020-12-30 20:59:27 -06:00
Dustin c92af29e84 roles/named: Send application logs to syslog
BIND sends its normal application logs (as opposed to query logs) to the
`default_debug` channel.  By sending these log messages to syslog, they
can be routed and rotated using the normal system policies.  Using a
separate dedicated log file just ends up consuming a lot of space, as it
is not managed by any policy.
2020-12-26 11:36:15 -06:00
Dustin 59e8244a08 roles/apache: Add tags to tasks
Adding tags to tasks makes them easier to run in isolation.
2020-12-26 11:35:45 -06:00
Dustin aa1ab75edd roles/apache: logrotate: Compress logs immediately
To conserve space on the log volume of web servers, "old" log files are
now compressed immediately, as opposed to waiting until the next
rotation.
2020-12-26 11:33:09 -06:00
Dustin b519f97f6a roles/apache: Disable ssl_request_log
I am not sure the point of having both `ssl_request_log` and
`ssl_access_log`.  The former includes the TLS ciphers used in the
connection, which is not particularly interesting information.  To save
space on the log volume of web servers using Apache, we should just stop
creating this log file.
2020-12-26 11:31:24 -06:00
Dustin d1cdc8bfc3 roles/cert: Add handler topic notification
Changing/renewing a certificate generally requires restarting or
reloading some service.  Since the *cert* role is intended to be generic
and reusable, it naturally does not know what action to take to effect
the change.  It works well for the initial deployment of a new
application, since the service is reloaded anyway in order for the new
configuration to be applied.  It fails, however, for continuous
enforcement, when a certificate is renewed automatically (i.e. by
`lego`) but no other changes are being made.  This has caused a number
of disruptions when some certificate expires and its replacement is
available but has not yet been loaded.

To address this issue, I have added a handler "topic" notification to
the *certs* role.  When either the certificate or private key file is
replaced, the relevant task will "notify" a generic handler "topic."
This allows some other role to define a specific handler, which
"listens" for these notifications, and takes the appropriate action for
its respective service.

For this mechanism to work, though, the *cert* role can only be used as
a dependency of another role.  That role must define the handler and
configure it to listen to the generic "certificate changed" topic.  As
such, each of the roles that are associated with a certificate deployed
by the *cert* role now declare it as a dependency, and the top-level
playbooks only include those roles.
2020-12-26 10:38:17 -06:00
Dustin 8a18c92730 roles/collectd-prometheus: Configure plugin
The *collectd-prometheus* role configures the *write_prometheus* plugin
for collectd.  This plugin exposes data collected or received by the
collectd process in the Prometheus Exposition Format over HTTP.  It
provides the same functionality as the "official" collectd Exporter
maintained by the Prometheus team, but integrates natively into the
collectd process, and is much more complete.

The main intent of this role is to provide a mechanism to combine the
collectd data from all Pyrocufflink hosts and insert it into Prometheus.
By configuring the collectd instance on the Prometheus server itself to
enable and use the *write_prometheus* plugin and to receive the
multicast data from other hosts, collectd itself provides the desired
functionality.
2020-12-26 09:44:04 -06:00
Dustin 8e180d00ab collectd: Ensure service is enabled 2020-12-23 21:25:49 -06:00
Dustin 8d442b2aaf roles/collectd: Support setting server interface
For hosts with multiple network interfaces, collectd may not send
multicast messages through the correct interface.  To ensure that it
does, the `Interface` configuration option can be specified with each
`Server` option.  To define this option, entries in the
`collectd_network_servers` list can now have an `interface` property.
2020-12-23 20:54:48 -06:00
Dustin cbbef24bbd collectd: Install and configure collectd
The *collectd* role, with its corresponding `collectd.yml` playbook,
installs *collectd* onto the managed node and manages basic
configuration for it.  By default, it will enable several plugins,
including the `network` plugin.  The `collectd_disable_plugins` variable
can be set to a list names of plugins that should NOT be enabled.

The default configuration for the `network` plugin instructs *collectd*
to send metrics to the default IPv6 multicast group.  Any host that has
joined this group and is listening on the specified UDP port (default
25826) can receive the data.  This allows for nearly zero configuration,
as the configuration does not need to be updated if the name or IP
address of the receiver changes.

This configuration is ready to be deployed without any variable changes
to all Pyrocufflink servers.  Once *collectd* is running on the servers,
we can set up a *collectd* instance to receive the data and store them
in a time series database (i.e. Prometheus).
2020-12-08 21:11:27 -06:00
Dustin 750cc8afd4 roles/logrotate: Install and enable logrotate
Since Apache HTTPD does not have any built-in log rotation capability,
we need `logrotate`.  Somewhere along the line, the *logrotate* package
stopped being installed by default.  Additionally, with Fedora 30, it
changed from including a drop-in file for (Ana)cron to providing a
systemd timer unit.

The *logrotate* role will ensure that the *logrotate* package is
installed, and that the *logrotate.timer* service is enabled and
running.  This in turn will ensure that `logrotate` runs daily.  Of
course, since the systemd units were added in Fedora 30, machines to
which this role is applied must be running at least that version.

By listing the *logrotate* role as a dependency of the *httpd* role, we
can ensure that `logrotate` manages the Apache error and access log
files on any server that runs Apache HTTPD.
2020-12-08 20:59:40 -06:00
Dustin 1e42959863 roles/bitwarden_rs: Update to new Docker image
The bitwarden_rs team now maintains its Docker images under the
*bitwardenrs* namespace on Docker Hub.
2020-11-13 06:52:56 -06:00
Dustin 132689a3b8 roles/protonvpn: Set infinite keying retries
By default, strongSwan will only attempt key negotiation once and then
give up.  If the VPN connection is closed because of a network issue, it
is unlikely that a single attempt to reconnect will work, so let's keep
trying until it succeeds.
2020-10-10 11:10:12 -05:00
Dustin 3a36d6b7ff hosts: Add motion0.p.b
*motion0.pyrocufflink.blue* hosts motionEye
2020-10-03 11:30:38 -05:00
Dustin ef4e769ed2 motioneye: Deploy motionEye camera software
The *motioneye* role installs motionEye on a Fedora machine using `pip`.
It configures Apache to proxy for motionEye for outside (HTTPS) access.

The official installation instructions and default configuration for
motionEye assume it will be running as root.  There is, however, no
specific reason for this, as it works just fine as an unprivileged user.
The only minor surprise is that the `conf_path` configuration setting
must be writable, as this is where motionEye places generated
configuration for `motion`.  This path does not, however, have to
include the `motioneye.conf` file itself, which can still be read-only.
2020-10-03 11:29:39 -05:00
Dustin 8ca093050b pyrocufflink-dns: Cloudflare over ProtonVPN
This commit adds a new playbook, `protonvpn.yml`, and its supporting
roles *strongswan-swanctl* and *protonvpn*.  This playbook configures
strongSwan to connect to ProtonVPN using IPsec/IKEv2.

With this playbook, we configure the name servers on the Pyrocufflink
network to route all DNS requests through the Cloudflare public DNS
recursive servers at 1.1.1.1/1.0.0.1 over ProtonVPN.  Using this setup,
we have the benefit of the speed of using a public DNS server (which is
*significantly* faster than running our own recursive server, usually by
1-2 seconds per request), and the benefit of anonymity from ProtonVPN.

Using the public DNS server alone is great for performance, but allows
the server operator (in this case Cloudflare) to track and analyze usage
patterns.  Using ProtonVPN gives us anonymity (assuming we trust
ProtonVPN not to do the very same tracking), but can have a negative
performance impact if its used for all Internet traffic.  By combining
these solutions, we can get the benefits of both!
2020-09-06 11:06:58 -05:00
Dustin f536c9633e roles/named: Support logging queries to syslog
This commit adds two new variables to the *named* role:
`named_queries_syslog` and `named_rpz_syslog`.  These variables control
whether BIND will send query and RPZ log messages to the local syslog
daemon, respectively.
2020-09-06 10:40:27 -05:00
Dustin 84313601ef roles/named: Implement response policy zones
BIND response policy zones (RPZ) support provides a mechanism for
overriding the responses to DNS queries based on a wide range of
criteria.  In the simplest form, a response policy zone can be used to
provide different responses to different clients, or "block" some DNS
names.

For the Pyrocufflink and related networks, I plan to use an RPZ to
implement ad/tracker blocking.  The goal will be to generate an RPZ
definition from a collection of host lists (e.g. those used by uBlock
Origin) periodically.

This commit introduces basic support for RPZ configuration in the
*named* role.  It can be activated by providing a list of "response
policy" definitions (e.g. `zone "name"`) in the `named_response_policy`
variable, and defining the corresponding zones in `named_zones`.
2020-09-06 10:40:01 -05:00
Dustin 44404950c1 Merge branch 'graylog' into master 2020-08-31 20:17:12 -05:00
Dustin b32b4a2c99 roles/ssh-hostkeys: Add missing host keys
Several new hosts did not have recorded SSH host keys:

* build1-aarch64
* build2-armv7hl
* hass1
* hassdb0
2020-08-28 21:17:02 -05:00
Dustin f1b4598601 roles/hassdb: Deploy Home Assistant database
Normally, Home Assistant uses a SQLite database for storing state
history.  On a Raspberry Pi with only an SD card for storage like
*hass1.pyrocufflink.blue*, this can become extremely slow, especially
for large data sets.  To speed up features like history and logbook,
Home Assistant supports using an external database engine such as
PostgreSQL or MariaDB.

The *hassdb* role and corresponding `hassdb.yml` playbook deploys a
PostgreSQL server for Home Assistant to use.  It needs only to create
the role and database, as Home Assistant manages its own schema.
2020-07-14 11:38:30 -05:00
Dustin a614f7b5c7 roles/postgresql-server: Remove postgresql-setup
The *postgresql-setup* service is no longer necessary, as upstream has
fixed the SELinux policy to allow root to invoke the `postgresql-setup`
command directly.
2020-07-14 10:56:01 -05:00
Dustin f4e5aacf52 roles/postgresql-server: Support SSL configuration
This commit adds a task to generate a PostgreSQL configuration file from
a template.  Previously, the default configuration file generated by
`initdb` was sufficient, but in order to enable SSL connections, some
changes to it are required.

Naturally, SSL connections require a server certificate, so the
*postgresql-server* role will now also copy certificate files to the
managed node, if any.
2020-07-14 10:52:25 -05:00
Dustin add233b9e8 roles/strongswan: Update service name
Fedora has renamed the *strongswan* service to *strongswan-starter*.
The *strongswan* service now controls strongSwan via Vici, which uses a
different configuration format and is not compatible with the files in
`/etc/strongswan/ipsec.d`.  As I am migrating everything to Wireguard
now, it does not make sense to rewrite all of the IPsec configuration in
this new format, so using the legacy format with the renamed service
makes more sense.
2020-07-04 14:32:22 -05:00
Dustin 7a4b46b455 Merge branch 'hass1' 2020-07-04 14:26:13 -05:00
Dustin b4db8eb74d roles/homeassistant: Add HTTPS redirect
Enforce HTTPS access to Home Assistant web UI using a redirect and HSTS.
2020-07-04 14:25:16 -05:00
Dustin b99c7aa27d roles/homeassistant: Install in a virtualenv
Because the Home Assistant user's home directory is on `/var`, Python
packages installed in the "user site" do not get the correct SELinux
labels and thus run in the wrong domain.  This causes a lot of AVC
denials and other issues that prevent Home Assistant from working
correctly.

To resolve this issue, Home Assistant is now installed in a virtual
environment at `/usr/local/homeassistant`.  This directory is still
owned by the Home Assistant user, allowing Home Assistant to manage
packages installed there.  Since it is rooted under `/usr`, files are
labelled correctly and processes launched from executables there will
run in the correct domain.
2020-07-04 14:25:16 -05:00
Dustin 0a48d1f325 roles/net-ifaces: Update VLAN for pyrocufflink.blue
The main network, *pyrocufflink.blue* (172.30.0.0/26) is now on VLAN 1
instead of VLAN 30.  This changed when I replaced the Cisco SG200-26
with the UniFI Switch 48, to simplify configuration of all of the
Ubiquiti devices.
2020-05-25 09:17:24 -05:00
Dustin e0624a62cf roles/nextcloud: Update to 18.0.2 2020-03-22 11:26:20 -05:00
Dustin 4c661478b2 hosts: bw0: Use Lego cert 2020-03-17 08:45:34 -05:00
Dustin bb73d28c05 websites/darkchestofwonders.us: Use Lego cert 2020-03-17 08:45:34 -05:00
Dustin e4ecd5d58a websites/proxy: Add reverse proxy configuration
For some time, I have been trying to design a new configuration for the
reverse proxy on port 443 to correctly handle all the types of traffic
on that port.  In the original implementation, all traffic on port 443
was forwarded by the gateway to HAProxy.  HAproxy then used TLS SNI to
route connections to the correct backend server based the requested host
name.  This allowed both HTTPS and OpenVPN-over-TLS to use the same
port, however it was not without issues.  A layer 4 (TCP) proxy like
this "hides" the real source address of clients connecting to the
backend, which makes IP-based security (e.g. rate limiting, blacklists,
etc.) impossible at the application level.  In particular, Nextcloud,
which implements rate limiting was constantly imposing login delays on
all users, because legitimate traffic was indistinguishable from
Internet background noise.

To alleviate these issues, I needed to change the proxy to operate in
layer 7 (HTTP) mode, so that headers like *X-Forwarded-For* and
*X-Forwarded-Host* could be added.  Unfortunately, this was not easy,
because of the simultaneous requirement to forward OpenVPN traffic.
HAProxy can only do SNI inspection in TCP mode.  So, I began looking for
an alternate way to proxy both HTTP and non-HTTP traffic on the same
port.

The HTTP protocol defines the `CONNECT` method, which is used by forward
proxies to tunnel HTTPS over plain HTTP.  OpenVPN clients support
tunneling OpenVPN over HTTP using this method as well.  HAProxy has
limited support for the CONNECT method (i.e. it doesn't do DNS
resolution, and I could find no way of restricting the destination) with
the `http_proxy` option, so I looked for alternate proxy servers that
had more complete support.  Unsurprisingly, Apache HTTPD has the most
complete implementation of the `CONNECT` method (Nginx doesn't support
it at all).  Using a name-based virtual host on port 443, Apache will
accept requests for *vpn.pyrocufflink.net* (using TLS SNI) and allow the
clients to use the `CONNECT` method to create a tunnel to the OpenVPN
server.  This requires OpenVPN clients to a) use *stunnel* to wrap plain
HTTP proxy connections in TLS and b) configure OpenVPN to use the
TLS-wrapped HTTP proxy.

With Apache accepting all incoming connections, it was trivial to also
configure it as a layer 7 forward proxy for Bitwarden, Gitea, Jenkins,
and Nextcloud.  Unfortunately, proxying for the other websites
(darkchestofwonders.us, chmod777.sh, dustin.hatch.name) was not quite as
straightforward.  These websites would need to have an internal name
that differed from their external name, and thus a certificate valid for
that name.  Rather than reconfigure all of these sites and set all of
that up, I decided to just move the responsibility for handling direct
connections from outside to the *web0* and eliminate the dedicated
reverse proxy.  This was not possible before, because Apache could not
forward the OpenVPN traffic directly, but now with the forward proxy
configuration, there is no reason to have a separate server for these
connections.

Overall, I am pleased with how this turned out.  It makes the OpenVPN
configuration simpler (*stunnel* no longer needs to run on the OpenVPN
server itself, since Apache is handling TLS termination), eliminates a
network hop for the websites, makes the reverse proxy configuration for
the other web applications much easier to understand, and resolves the
original issue of losing client connection information.
2020-03-16 14:19:08 -05:00
Dustin 1de8e9fa90 websites/pyrocufflink.net: Add HTTP virtual host
A name-based HTTP (not HTTPS)  virtual host for *pyrocufflink.net* is
necessary to ensure requests are handled properly, now that there is
another HTTP virtual host (chmod777.sh) defined on the same server.
2020-03-16 14:17:51 -05:00
Dustin 0694594445 websites/pyrocufflink.net: Use lego certificate
This commit updates the configuration for *pyrocufflink.net* to use the
wildcard certificate managed by *lego* instead of an unique certificate
managed by *certbot*.
2020-03-16 14:16:34 -05:00
Dustin db6d13013a websites: Add chmod777.sh
*chmod777.sh* is a simple static website, generated by Hugo.  It is
built and published from a Jenkins pipeline, which runs automatically
when new commits are pushed to Gitea.

The HTTPS certificate for this site is signed by Let's Encrypt and
managed by `lego` in the `certs` submodule.
2020-03-09 20:29:52 -05:00
Dustin 2b49c5a02e roles/dch-proxy: Configure proxy for Nextcloud
This commit adds front-end and back-end configuration for HAProxy to
proxy HTTP/HTTPS for
*nextcloud.pyrocufflink.net*/*nextcloud.pyrocufflink.blue* to
*cloud0.pyrocufflink.blue*.
2020-03-09 20:24:28 -05:00
Dustin b09bf84a3b nextcloud: Deploy Nextcloud w/ Apache+PHP-FPM
The *nextcloud* role installs Nextcloud from the specified release
archive, downloading it to the control machine first if necessary, and
configures Apache and PHP-FPM to serve it.

The `nextcloud.yml` playbook uses the *cert* role to install the X.509
certificate for the Nextcloud server, sets up Apache HTTPD with the
*apache* role, and installs Nextcloud using the *nextcloud* role.

The host *cloud0.pyrocufflink.blue* is the Nextcloud server for
Pyrocufflink.
2020-03-09 20:18:07 -05:00
Dustin 2aaf8c5239 roles/cert: Common role for installing certs
The *cert* role is intended to be a generic, reusable role to copy an
X.509 certificate and/or private key file to managed nodes.  It is
intended to be included in a playbook with at least the `cert_src` and
`cert_dest` variables defined, e.g.:

```
- hosts: whatever
  roles:
  - role: cert
    cert_src: whatever.cer
    cert_dest: /path/to/whatever.cer
```
2020-03-09 20:17:47 -05:00
Dustin dd0892e208 roles/haproxy: Fix undefined var on Fedora hosts
the `haproxy_ssl_default_bind_options` variable is not defined for
machines running Fedora, because this parameter is not used in the
default configuration file there.
2020-03-03 19:27:19 -06:00
Dustin cd1cf38774 hosts: git0: Switch to Lego wildcard cert 2020-02-22 16:43:46 -06:00
Dustin f8b7f28469 roles/gitea: Install from upstream binary
I seem to have forgotten how I got the RPM for Gitea.  I think I built
it, but I cannot find the spec file, nor the RPM package.  Since this is
clearly not reproducible, I decided to switch to using the binary
provided by upstream for now, until either I or Fedora get around to
making a better RPM.

Installing Gitea from the upstream binary is simple: just download it
and copy it to `/usr/local/bin`.  Of course, the OS user and systemd
unit have to be managed by configuration policy when it's installed this
way.
2020-02-22 16:43:46 -06:00
Dustin 7543815e9b hosts: Add burp1.p.b
*burp1.pyrocufflink.blue* will replace *burp0.pyrocufflink.blue* as the
BURP server for Pyrocufflink.  It is a physical machine (Fitlet), making
it simpler to manage the USB drives.  The old virtual machine will be
decommissioned soon.
2020-01-25 13:57:04 -06:00
Dustin d290eca833 roles/burp-server: switch to version_compare test
Ansible replaced the `version_compare` filter with a `version_compare`
test that does the same thing.  The former is completely gone now,
causing the template to fail to render, so its usage of that filter
needs to be updated.
2020-01-25 13:54:42 -06:00
Dustin 87843e5926 burp-client: Use burp.p.b name
Using the generic *burp.pyrocufflink.blue* name will allow easier
transition to a new BURP server.  However, since this is not the actual
name, it cannot be used for task delegation, so a separate variable is
required to store the real name of the BURP server.  This is only used
during client deployment, and not by BURP itself.
2020-01-18 12:10:53 -06:00
Dustin e25b9a2e8e hosts: Add logs0.p.b
*logs0.pyrocufflink.blue* hosts Graylog
2019-10-28 18:47:09 -05:00
Dustin 3aad9c1dda roles/graylog: Add Graylog server deployment
The *graylog* role installs Graylog from the *graylog2.org* Yum
repository and manages basic server configuration.  It augments the
default systemd unit to provide the `CAP_NET_BIND_SERVICE` capability to
the Graylog server process via ambient capabilities, thereby allowing
the server to bind to the privileged Syslog UDP port.
2019-10-28 18:47:09 -05:00
Dustin 07eb3633e3 roles/mongodb: Add MongoDB deployment
The *mongodb* role installs MongoDB from the *mongodb.org* Yum
repository and manages basic server configuration.
2019-10-28 18:34:45 -05:00
Dustin dd4ccb3a32 roles/elasticsearch: Add Elasticsearch deployment
The *elasticsearch* role installs Elasticsearch from the Elastic.co Yum
repository and manages basic node configuration.
2019-10-28 18:33:37 -05:00
Dustin c57de29054 roles/hass-dhcp: Enable DNS query logging 2019-09-19 19:50:35 -05:00
Dustin a1c90272b5 roles/freeradius: Set dhparam permissions
The `dhparam` file used by FreeRadius needs to be readable by the
*radiusd* group.
2019-09-19 19:50:35 -05:00
Dustin 2914bdb73c roles/certbot: Ensure certbot is configured first
The `Alias` configuration for Certbot needs to be configured before any
other locations, to ensure the `/.well-known` path is always served from
the local filesystem.  If another drop-in configuration file (e.g.
`bitwarden.conf`) is ordered before it, it may override this
configuration and prevent Let's Encrypt from working.
2019-09-19 19:50:35 -05:00
Dustin fb352cc920 jenkins-slave: Allow Jenkins to connect to Docker
In order to allow Jenkins to connect to the Docker daemon socket, the
socket must be owned by the *docker* group, and the *jenkins* user must
be a member of it.
2019-09-19 19:50:35 -05:00
Dustin b2cc467581 hosts: Add build0-amd64
*build0-amd64.securepassage.com* is a Jenkins agent that runs Docker,
allowing pipeline jobs to run inside containers.
2019-09-19 19:50:35 -05:00
Dustin c676aa2a0b roles/dch-proxy: Add haproxy config for Bitwarden
This commit adds an HAProxy backend for Bitwarden, and adds ACL rules to
the frontend to proxy traffic to *bitwarden.pyrocufflink.blue* or
*bitwarden.pyrocufflink.net* to it.
2019-09-19 19:27:30 -05:00
Dustin c68f9bb6af hosts: dc0.p.b: Renew Samba TLS certificate
Since the same certificate is used for LDAPS and RADIUS (EAP-TLS), it
makes more sense to store it only once, with the later file as a symlink
to the former.
2019-09-19 19:27:30 -05:00
Dustin 6e57abfe2e bitwarden_rs: Configure BURP client
This commit configures *bw0.pyrocufflink.blue* as a BURP client, so that
the Bitwarden data can be backed up.  A pre-backup script is used to
take a consistent snapshot of the SQLite database before copying it to
the BURP server.
2019-09-19 19:27:30 -05:00
Dustin e8ca37fa7c roles/burp-client: Set clientconfdir file owner
The BURP server runs as user *burp*, and nas such, requires that the
client-specific configuration files be owned by that user so they can be
read when a client connects.
2019-09-19 19:27:30 -05:00
Dustin 799d24f4b9 roles/burp-client: Update burp.conf for newer BURP
Newer versions of the BURP client require `status_port` to be set.  This
commit updates the `burp.conf.j2` template to more closely match the
default configuration shipped with the *burp* package, including setting
this new value.
2019-09-19 19:27:30 -05:00
Dustin e813008c86 roles/bitwarden_rs: Install sqlite
The `sqlite3` command is required to take consistent backups of the
Bitwarden_rs database.
2019-09-19 19:27:30 -05:00
Dustin 9306252e75 hosts: Add bw0.p.b
*bw0.pyrocufflink.blue* runs Bitwarden_rs via Docker.
2019-09-19 19:27:30 -05:00
Dustin 14cb924ba7 bitwarden_rs: Deploy Bitwarden_rs using Docker
The *bitwarden_rs* role sets up the Bitwarden_rs server using its
official Docker container.  It sets up Apache as a reverse proxy for TLS
support.
2019-09-19 19:27:29 -05:00
Dustin 1f535e980f roles/docker: Install and set up Docker daemon
The *docker* role configures the Docker daemon on the managed machine.
2019-09-19 19:27:12 -05:00
Dustin f368938550 roles/gitea: Add Oauth2 JWT Secret
Newer versions of Gitea need a JWT secret for Oauth2.  Gitea will
attempt to generate one at startup if it is not already specified in the
configuration file, but this will fail since the file is not writable by
the user running the service.  As such, it must be set via configuration
policy.
2019-04-24 16:18:19 -05:00
Dustin d8704fcb43 ssh-hostkeys: Add key for hass0.p.b 2019-03-22 16:53:43 -05:00
Dustin c8d6bae093 wheelhost: Publish wheels built by Jenkins
The point of the "wheel host" is to serve as a repository of Python
packages (wheels) built by Jenkins for consumption by `pip` et al. For
applications and libraries that do not provide all of their dependencies
as binary packages, this makes a convenient way to install them without
requiring all of the build tools and dependencies on the destination
machine.

The idea here is that a Jenkins job runs `pip wheel` for a distribution
package name or `requirements.txt` file and then uploads the resulting
wheel files using `rsync`. Apache is configured to serve the upload
directory with an index compatible with `pip`'s `--find-links`.
2019-03-22 10:19:27 -05:00
Dustin 2265dd235b roles/hass-dhcp: Deploy DHCP server for HA
The *hass-dhcp* role installs dnsmasq and configures it to serve DHCP
requests on the Home Assistant network. Since this network is not
routed, the regular DHCP relay/server setup will not work.
2019-03-22 09:43:30 -05:00
Dustin 51d6e13a13 websites: pyrocufflink.net: Disable rewrite log 2019-03-22 09:34:50 -05:00
Dustin cb92f47b4d roles/samba: Manage LDAP TLS certificates
This commit adds tasks to the *samba-dc* role to install TLS
certificates for the Samba LDAP server, and configures Samba to use
them.
2019-03-22 09:31:19 -05:00
Dustin b0690f942f roles/taiga: Fix HTTP->HTTPS redirect
The HTTP->HTTPS redirect must be defined in global scope in order for it
to work.
2019-03-22 09:29:56 -05:00
Dustin 7e585445b9 roles/vmhost: Enable KSM
This commit adds a systemd unit to enable the Kernel Same-page Merging
daemon on VM hosts. This allows much greater virtual machine density,
especially when many VMs are running the same guest OS.
2019-03-22 09:29:56 -05:00
Dustin 909c8e7a03 roles/haproxy: Add support for Debian hosts
Debian does not support system-wide SSL cipher suite profiles of course,
so these options need to be specified explicitly when deploying HAProxy
on Debian-based machines.
2019-03-22 09:29:56 -05:00
Dustin ceb56edf06 roles/net-ifaces: Create bridges for mgmt and hass
This commit updates the net-ifaces scripts for both *vmhost0* and
*vmhost1* to create VLAN and bridge interfaces for the Management and
Home Assistant networks.
2019-03-22 09:29:56 -05:00
Dustin 691461cd8c roles/winbind: Fix error handling in ads_member
This commit fixes a couple of issues with the `ads_member` module
surrounding handling of errors from the `net ads join` command.
2019-03-22 09:29:56 -05:00
Dustin a9d3b7894e roles/dhcpd: Support UniFi DHCP option 43
The `ubnt.unifi-address` DHCP option can be set to provide Ubiquiti
hardware with the hostname of the UniFi controller.
2019-03-22 09:29:56 -05:00
Dustin 5d47aad8a9 roles/zabbix: Add support for Debian
The *zabbix-agent* package for Debian locates configuration and log
files differently from other distributions.
2019-03-22 09:29:56 -05:00
Dustin 1a62a780ca hosts: Add taiga0.pyrocufflink.blue 2019-03-22 09:29:56 -05:00
Dustin d842b0ad25 roles/ssh-hostkeys: Sort ssh_known_hosts
Keep this file sorted using `ex`:

    ex -c 'sort|x' roles/ssh-hostkeys/files/ssh_known_hosts
2019-03-07 13:31:41 -06:00
Dustin 26ee57c6ca roles/rabbitmq: Deploy RabbitMQ
The *rabbitmq* role installs and configures the RabbitMQ message broker.
2019-03-07 13:29:29 -06:00
Dustin 251611803f roles/taiga: Deploy Taiga project management app
The *taiga* role installs the three components of Taiga:

* taiga-back
* taiga-events
* taiga-front

*taiga-back* is a Python application. Its dependencies are installed via
`pip` in the *taiga* user's site-packages, and the application itself is
installed by unpacking the archive. *taiga-events* is a Node.js
application. Its dependencies are installed by `npm`, and is itself
installed by unpacking the archive. Finally, *taiga-front* is a
single-page browser application that is installed by unpacking the
archive, and served by Apache.

Taiga requires PostgreSQL and RabbitMQ.
2019-03-07 13:26:15 -06:00
Dustin 960528c001 roles/homeassistant: Deploy Home Assistant
This commit introduces a *homeassistant* role that installs and sets up
Home Assistant using `pip`.
2019-03-05 18:30:29 -06:00
Dustin f4fad034dc roles/dch-proxy: Proxy pyrocufflink.net 2019-01-04 20:52:23 -06:00
Dustin ed5f7108dc websites: Add role for pyrocufflink.net site
The *websites/pyrocufflink.net* role configures the public web server to
host *pyrocufflink.net*. This site has two functions:

* It redirects `/` to http://dustin.hatch.name/
* It proxies user home directories (i.e. /~dustin/) to the file server
2019-01-04 20:52:23 -06:00
Dustin 52a9fb1c0e roles/apache: Set ServerName in default SSL vhost
The `ServerName` directive needs to be set inside the default SSL vhost,
as this property does not get inherited from the global configuration,
and it is needs to be set in order for SNI to work correctly.
2019-01-04 20:52:23 -06:00
Dustin ea1f52814d roles/apache: Configure mod_userdir
By default, per-user directories (i.e. `/~username/`) are disabled in
Fedora's configuration of Apache. This commit introduces a new variable,
`apache_userdir`, which can be used to enable this feature. It should be
set to a string other than *disabled*, which is the path under users'
home directories that will be served, if it is accessible. Normally, the
value would be `public_html`.
2019-01-04 20:52:23 -06:00
Dustin 972dbd1fdf websites/dcow: Add certbot role dependency
To support multiple websites with separate Let's Encrypt certificates,
the *certbot* role needs to be applied as a dependency of each
individual website role. This will allow each application to specify a
different value for `certbot_domains`.
2019-01-04 20:52:23 -06:00
Dustin d1a72de6b0 roles/certbot: Run periodically as certbot user
The default systemd unit configuration for *certbot-renew.service* runs
the `certbot renew …` command as root. This can cause permissions
issues, since this Ansible role expects the *certbot* user to be able to
access all configuration, data, and log files. As such, this commit adds
a systemd unit extension for *certbot-renew.service* to run the command
as *certbot*.
2019-01-04 20:52:23 -06:00
Dustin b61070fea8 dch-openvpn: Support road-warrior clients
Moving the route definitions to global scope, and defining an address
pool, will allow other clients besides *dhatch-d4b* to connect to and
use the OpenVPN tunnel service. This may be useful in situations where
IPsec is blocked
2018-10-07 21:42:18 -05:00
Dustin a1ca06a3c5 Move VPN server to dedicated VM
The VPN capability of the UniFi Security Gateway is extremely limited.
It does not support road-warrior IPsec/IKEv2 configuration, and its
OpenVPN configuration is inflexible. As with DHCP, the best solution is
to simply move service to another machine.

To that end, I created a new VM, *vpn0.pyrocufflink.blue*, to host both
strongSwan and OpenVPN. For this to work, the necessary TCP/UDP ports
need to be forwarded, of course, and all of the remote subnets need
static routes on the gateway, specifying this machine as the next hop.
Additionally, ICMP redirects need to be disabled, to prevent confusing
the routing tables of devices on the same subnet as the VPN gateway.
2018-10-07 21:42:18 -05:00
Dustin 07356697c8 roles/dch-openvpn-server: Use firemon_networks
The routes to FireMon networks are now defined using the
`firemon_networks` Ansible variable. The global `iroute` and
client-specific `route` options are generated from the CIDR blocks
specified in this list.
2018-08-26 17:32:23 -05:00
Dustin 88dd80e6fd aria2: Deploy aria2 download manager
The *aria2* role installs the *aria2* download manager and sets it up to
run as a system service with RPC enabled. It also sets up the web UI,
though that must be installed manually from an archive, for now.
2018-08-19 14:17:48 -05:00
Dustin f250e00a17 roles/named: Provide default for named_keys
For hosts that do not have any TSIG keys, the `named_keys` variable
still must be defined (to an empty iterable) in order for the template
to expand properly.
2018-08-12 18:06:14 -05:00
Dustin 07a23267c6 hosts: Add dns1.pyrocufflink.blue
To avoid having a single point of failure, a second recursive DNS server
is necessary. This will be useful in cases where the VM hosts must both
be taken offline, but Internet access is still required.

The new server, *dns1.pyrocufflink.blue*, has all the same zones defined
as the original. It forwards the *pyrocufflink.blue* zone and
corresponding reverse zones to the domain controllers, and acts as a
slave for the *pyrocufflink.red* zone.
2018-08-12 17:24:37 -05:00
Dustin 26f3637bfa hosts: Add proxy0.pyrocufflink.blue
As its name suggests, *proxy0.pyrocufflink.blue* acts as an HTTP proxy
server running Squid.
2018-08-12 16:00:53 -05:00
Dustin b86ecb99fd squid: Add role and PB to deploy Squid 2018-08-12 16:00:32 -05:00
Dustin 72b148bd0e hosts: Add smtp1.p.b
*smtp1.pyrocufflink.blue* is a VM that will replace
*smtp0.pyrocufflink.blue*, a Raspberry Pi.

I decided that there is little use in having the availability guarantee of
a discreet machine for the SMTP relay. The only system that would NEED
to send mail if the VM host fails is Zabbix, which operates as its own
relay anyway. As such, the main relay can be a VM, and the Raspberry Pi
can be repurposed as a recursive DNS server.
2018-08-12 15:22:31 -05:00
Dustin 18ed14f376 Add SSH host keys for burp0.p.b 2018-08-12 10:27:20 -05:00
Dustin 4e8bd8995b hosts: Add koji0.pyrocufflink.blue
*koji0.pyrocufflink.blue* hosts the Koji ecosystem, including a builder.
2018-08-12 10:27:20 -05:00
Dustin a0dd911a63 roles/koji-builder: Deploy the Koji builder
The *koji-builder* role installs and configures the Koji builder
(*kojid*). It supports configuring an HTTP proxy, if required.
2018-08-12 10:14:25 -05:00
Dustin da4ec1612c roles/koji-web: Deploy the Koji Web UI
The *koji-web* role installs and configures the Koji Web GUI front-end
for Koji. It requires Apache and mod_wsgi. A client certificate is
required for authentication to the hub, and must be placed in the
host-specific subdirectory of `certs/koji`.
2018-08-12 10:08:01 -05:00
Dustin 6341d972f6 roles/koji-client: Configure the koji client
The *koji-client* role is a generic role that can be used to configure
the Koji client library/`koji` CLI tool. By default, it manages the
default configuration at `/etc/koji`, but by using the
`koji_client_dir`, `koji_client_user`, and `koji_client_id` variables,
it can be used to configure per-user client configuration as well.
2018-08-12 10:05:56 -05:00
Dustin aed2776e27 roles/kojira: Deploy the Koji repository agent
The *kojira* role sets up the Koji repository agent to manage
repository metadata for build tags. It runs as a daemon, usually on the
same machine as the Koji hub. A client certificate is required for
authentication, and must be supplied by placing it in the
`certs/koji/{{ inventory_hostname }}` directory.
2018-08-12 10:04:23 -05:00
Dustin 1a8d7ce29a roles/koji-gc: Deploy the Koji garbage collector
The *koji-gc* role sets up the Koji garbage collector utility to run
periodically. It uses cron for scheduling. A client certificate is
required for authentication, and must be supplied by placing it in the
`certs/koji/{{ inventory_hostname }}` directory.
2018-08-12 09:58:56 -05:00
Dustin 760d3f4aec roles/koji-hub: Deploy the Koji Hub
The *koji-hub* role installs and configures the Koji Hub. It requires
Apache and mod_wsgi. Management of client certificates must be done
externally.
2018-08-12 09:33:08 -05:00
Dustin a810e9c691 roles/cronie: Install cronie
The minimal Fedora installation does not include a cron implementation.
The *cronie* role can be applied to hosts installed in this way to
ensure that cron is available for task scheduling.
2018-08-08 21:38:56 -05:00
Dustin 47999302cf roles/dch-vpn-server: Update remote access DNS
This commit updates the DNS server addresses pushed to remote access VPN
clients to use the new DNS server on the *pyrocufflink.blue* network.
2018-08-08 21:37:30 -05:00
Dustin b7fafa6734 roles/burp-client: Deploy BURP client
The *burp-client* role installs and configures a BURP client. It should
support RHEL/CentOS/Fedora and Gentoo.

To manage the client password and other server-mandated configuration,
the role uses Ansible's delegation feature to generate a configuration
file in the "clientconfdir" on the BURP server.

An hourly cron task is scheduled that runs `burp -a t` every hour. This
allows the server to configure backup timebands and intervals.
2018-08-08 20:11:46 -05:00
Dustin ddd7031624 roles/burp-server: Deploy BURP server
The *burp-server* role installs and configures a BURP server. It is
adapted from a previous iteration, and should support CentOS/RHEL/Fedora
and Gentoo, as well as both BURP 1.x and 2.x (depending on which version
gets installed by the system package manager).

To manage the certificate authority, the *burp-server* role uses the
`burp_ca` command. This has the advantage of not requiring any external
certificate management, but effectively binds the CA to a specific
machine.
2018-08-08 20:08:16 -05:00
Dustin 0a975ae4af roles/postfix: Vary shlib directory by arch
The value of the `shlib_directory` is dependent the system architecture.
Specifically, x86_64 machines use `/usr/lib64/postfix`, while everything
else uses `/usr/lib/postfix`. This role was originally deployed on a
Raspberry Pi, so the original path was correct. Attempting to deploy it
on an x86_64 machine revealed the error.

This commit adds a new task that loads a variables file based on the
architecture. Each option defines an `arch_libdir` variable, which can
be expanded in the `postfix_shlib_directory` variable as needed.
2018-08-07 19:51:09 -05:00
Dustin 4d45d727cb roles/dch-proxy: Remove backend myala
*myala.pyrocufflink.jazz* no longer hosts any public-facing websites,
and is in fact shut down. To prevent HAproxy from failing to start
because it cannot resolve the name, this backend needs to be removed.
2018-08-03 00:27:32 -05:00
Dustin a58b0f6523 Add SSH host key for web0 2018-08-01 22:29:40 -05:00
Dustin b4bcb12750 Add SSH host keys for vmhost0, vmhost1 2018-08-01 22:11:40 -05:00
Dustin 69a7e869b4 hosts: Add file0.p.b 2018-08-01 22:11:40 -05:00
Dustin 84a5d66b7a roles/fileserver: Deploy Samba file server
The *fileserver* role configures Samba as a file sharing server. It uses
the *samba* role to handle cross-distribution installation of Samba
itself, and is focused primarily on configuring shared folders.
2018-08-01 22:04:07 -05:00
Dustin f078522d97 roles/vmhost: Open libvirt migration firewall port 2018-07-29 10:39:36 -05:00
Dustin da79e8482c vmhost1: Update net-ifaces script 2018-07-29 10:39:12 -05:00
Dustin a95937d111 roles/dch-storage-net: Add After device dependency
This commit adds an *after* ordering dependency on the network device
unit to the *wait-global-address@.service* template unit. Without this
dependency, the service will wait forever for a global address if the
device does not exist. With the dependency, though, if the device does
not appear within the default timeout, the wait service will never
start, causing all dependent services to fail, but allowing the boot
process to continue.
2018-07-29 10:14:00 -05:00
Dustin 131c872d32 Merge remote-tracking branch 'refs/remotes/origin/master' 2018-07-29 10:02:28 -05:00
Dustin 9bf2a911c6 roles/dch-proxy: Switch default backend to web0.p.b
The public-facing websites are now hosted by *web0.pyrocufflink.blue*
and *myala.pyrocufflink.jazz* has been decommissioned.
2018-07-29 09:41:10 -05:00
Dustin 33ee3bf08d websites: Add role for darkchestofwonders.us
The *websites/darkchestofwonders.us* role prepares a machine to host
http://darkchestofwonders.us/. The website itself is published via rsync
by Jenkins.
2018-07-29 09:34:41 -05:00
Dustin 1f16b4c3e4 websites: Add role for nratonpass.com
The *websites/nratonpass.com* role prepares a machine to host
http://nratonpass.com/. The website itself is published via rsync by
Jenkins.
2018-07-29 09:34:21 -05:00
Dustin ae5d8bee56 websites: Add role for ebonfire.com
The *websites/ebonfire.com* role prepares a machine to host
http://ebonfire.com/. The website itself is published via rsync by
Jenkins.
2018-07-29 09:33:31 -05:00
Dustin 3d46e6b411 websites: Add role for dustin.hatch.name
The *websites/dustin.hatch.name* role configures a server to host
http://dustin.hatch.name/. The role only applies basic configuration;
the actual website application is published by Jenkins.
2018-07-29 09:32:19 -05:00
Dustin 4a5d319a17 roles/certbot: Reload Apache before cert requests
The Apache service needs to be reloaded after the *certbot* role
configures it to serve the `/.well-known/acme-challenge` path, so that
the changes can take effect before the `certbot` command is run to
request the certificate(s).
2018-07-29 09:28:12 -05:00
Dustin 9f5f692b6a roles/apache: Do not start Apache
If another role that depends on the *apache* role accidentally creates
an invalid configuration, it will be impossible to correct it by
subsequent invocations of its playbook. This is because the *apache*
role always tries to start the service, which will fail if the
configuration is invalid, thus aborting the playbook. With this early
abort, there is no way for later tasks to correct the error.

Playbooks that include the *apache* role should have a task that is
executed after all the roles have been applied to ensure the service is
running.
2018-07-29 09:25:54 -05:00
Dustin e8f9f48bfd roles/winbind: Actually perform domain join 2018-07-26 16:54:03 -05:00
Dustin 11dc40bc76 hosts: Add vmhost{0,1}.p.b 2018-07-23 17:35:10 -05:00
Dustin f8ae016042 roles/dch-storage-net: Set up/mount shared storage
The *dch-storage-net* role configures a machine to connect the storage
network and mount shared folders from the storage appliance.

The `wait-global-address.sh` script and corresponding
*wait-global-address@.service* systemd unit template are necessary to
ensure that the storage network is actually available before attempting
to mount the shared volumes. This is particularly important at boot,
since `dhcpcd` does not implement any kind of signaling that can be used
by *network-online.target*, so the network is considered "online" as
soon as the `dhcpcd` process has started. This typically results in
"network unreachable" errors.
2018-07-23 17:35:10 -05:00
Dustin abd05f8443 roles/vmhost: Configure libvirtd+QEMU
The *vmhost* role installs and configures the libvirt daemon to host
QEMU/KVM virtual machines.
2018-07-23 17:35:10 -05:00
Dustin 704850caa9 roles/net-ifaces: Configure virtual net interfaces
The *net-ifaces* role manages a script that creates virtual network
interfaces, such as bridge, bond, and VLAN, that `dhcpcd`/`dhclient`
alone cannot. This provides a lightweight alternative to
*systemd-networkd* and *NetworkMangager*.
2018-07-23 17:35:10 -05:00
Dustin 44a82688e4 roles/dhcpcd: Always send FQDN
Though the default for the `fqdn` value is listed as `both` in
*dhcpcd.conf(5)*, the current behavior of `dhcpcd` suggests that it may
actually be `none`. Without explicitly setting `fqdn both`, the value of
the kernel node name is sent as-is in the *hostname* option (12). If the
node name is set to the FQDN, then dynamic DNS gets broken, since the
DHCP server always appends its domain name to the provided hostname.
Setting `fqdn both` causes `dhcpcd` to send the FQDN in the *FQDN*
option (81), which the DHCP server interprets correctly.
2018-07-23 17:35:10 -05:00
Dustin 1302cd8825 roles/dhcpcd: Use a list for allow/deny interfaces
Using a list to specify the values for the `allowinterfaces` and
`denyinterfaces` parameters in `dhcpcd.conf` makes the configuration
policy cleaner and more type-safe.
2018-07-23 17:35:10 -05:00
Dustin a3b0349b4c roles/freeradius: Enable/start service
The *radiusd* service needs to be set to start on boot, lest the WiFi
goes down when the server is rebooted!
2018-07-23 12:25:14 -05:00
Dustin da2d73b676 roles/dhcpcd: Disable device management module
Today I realized that `dhcpcd` has been logging several hundred thousand
of these messages every second:

    libudev: received NULL device

This was causing both `dhcpcd` and `systemd-journald` to consume 100%
CPU.

I am not entirely sure what a "device management" module is in the
context of `dhcpcd`, but it does not seem to be required. Setting the
`nodev` option in `dhcpcd.conf` suppresses the messages, and seems to
have no effect on the operation of the daemon.
2018-07-20 17:46:47 -05:00
Dustin c88ee8bd99 dch-gw: Restrict traffic from Management network
Traffic from the management network is not allowed except for specific
services. NTP is required of course, for time synchronization with the
pyrocufflink.blue domain controllers. RADIUS is necessary for WiFi
authentication, which is also handled by the DCs.
2018-07-15 12:16:43 -05:00
Dustin 6e77d3cf07 roles/dch-openvpn-server: Add FireMon Mgmt subnet 2018-07-14 19:16:40 -05:00
Dustin 16a883f2f1 roles/ssh-hostkeys: Add keys for jenkins0.p.b 2018-07-03 13:30:34 -05:00
Dustin 03e5764de1 roles/dch-openvpn-server: Correct routes
The `ifconfig` global directive specifies the IP address added to the
tunnel interface device, not the network. The `push route` directives
need to include this address to correctly send route information to
clients.
2018-07-01 16:47:43 -05:00
Dustin c3f1f5750d roles/dch-proxy: Add OpenVPN backend
The `openvpn` haproxy backend allows forwarding TLS traffic for
*vpn.securepassage.com* to the OpenVPN-over-TLS service on the gateway.
2018-07-01 15:17:14 -05:00
Dustin e3c003e4aa hosts: gw0: Add OpenVPN certs/key 2018-07-01 15:16:51 -05:00
Dustin 780c8783db roles/dch-openvpn-server: Deploy OpenVPN server
The *dch-openvpn-server* role installs and configures OpenVPN and
stunnel to provide both native OpenVPN service as well as
OpenVPN-over-TLS. The latter uses stunnel, listening on TCP port 9876,
to allow better firewall traversal and TCP port sharing via reverse
proxy.
2018-07-01 15:14:23 -05:00
Dustin a02ddbb53f roles/apache: Support setting ServerTokens
The `apache_server_tokens` variable can now be set, which controls the
value of the `ServerTokens` directive. If the variable is set, the
`ServerTokens` directive will be added to the `00-servername.conf` file.
2018-06-23 14:42:45 -05:00
Dustin 10d6b52460 roles/samba: Support selecting interfaces
The `samba_interfaces` variable can now be defined to populate the
`interfaces` global configuration parameter in `smb.conf`. This
parameter controls the interfaces or addresses to which the Samba server
binds, and also the IP addresses that are registered in DNS.
2018-06-23 14:42:45 -05:00
Dustin 9d54411d52 roles/dch-proxy: Add backend for Jenkins
This commit configures HAProxy to proxy *jenkins.pyrocufflink.net* and
*jenkins.pyrocufflink.blue* to the Jenkins master.
2018-06-23 14:42:45 -05:00
Dustin c95a4b7379 roles/certbot: Support using existing account data
The *certbot* role now supports copying the data for an existing Let's
Encrypt account to the managed node using an archive. If an archive
named for the inventory hostname (typically the FQDN) of the managed
node is found in the `accounts` directory under the `files` directory of
the *certbot* role, it will be copied to the managed node and extracted
at `/var/lib/letsencrypt/accounts`. This takes the place of running
`certbot register` to sign up for a new account.
2018-06-23 13:44:34 -05:00
Dustin 52436acb48 roles/certbot: Add some task tags
The *install* tag is applied to any task that installs a package.

The *user* tag is applied to any task that creates an OS user or group.

The *group* tag is applied to any task that creates an OS user group.
2018-06-23 13:43:14 -05:00
Dustin f78fe14eae roles/zabbix: Respect host_uses_firewalld
For machines that do not use firewalld, the *zabbix-agent* role will now
skip attempting to open the Zabbix agent port using the `firewalld`
module. The `host_uses_firewalld` variable controls this behavior.
2018-06-19 20:37:09 -05:00
Dustin b5ea6b702a roles/ssh-hostkeys: Add keys for rprx0.p.b 2018-06-18 20:08:30 -05:00
Dustin 7b687db1c1 roles/ssh-hostkeys: Add keys for git0.p.b 2018-06-18 20:08:12 -05:00