Commit Graph

423 Commits (19f0d713f4bf40a0bb4b7d68c689b64849c34391)

Author SHA1 Message Date
Dustin 19f0d713f4 hosts: Move koji0.p.b to offline
I doubt I will be using Koji much if at all any more.  In preparation
for decommissioning it, I am moving the Koji inventory to hosts.offline,
to prevent Jenkins jobs from failing.
2020-12-13 09:54:01 -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 1c575c4340 protonvpn: Connect to server by IP address
Since DNS only allowed to be sent over the VPN, it is not possible to
resolve the VPN server name unless the VPN is already connected.  This
naturally creates a chicken-and-egg scenario, which we can resolve by
manually providing the IP address of the server we want to connect to.
2020-09-23 18:50:06 -05:00
Dustin 53bc4eac6d ci: Add pipeline for Pyrocufflink DNS 2020-09-06 11:10:50 -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 a7b8e2fbfa pyrocufflink-dhcp: Remove obsolete networks
* pyrocufflink.jazz has been gone for a while now
* tachyglossus.net DHCP is managed by the USG now
2020-09-06 10:40:27 -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 451df9042c ci: Add Jenkins pipeline for Home Assistant 2020-08-29 14:34:50 -05:00
Dustin 40c8df1b13 hosts: cloud0: Configure backups with BURP
Back up `/var/www/html`.
2020-08-29 14:22:17 -05:00
Dustin da3eb1aaf0 hosts: hass1: Configure backups with BURP
Back up `/var/lib/homeassistant`.
2020-08-29 14:22:17 -05:00
Dustin 7b49309803 hassdb: Fix playbook
* Need to apply the *postgresql-server* role to ensure PostgreSQL is
  properly configured
* Need to supply a PostgreSQL certificate (use Let's Encrypt so we don't
  have to manage a CA)
* Missing Ansible Vault file that includes the DB user password
2020-08-29 14:22:17 -05:00
Dustin 9ef88da95f hosts: hassdb0: Add missing vars file 2020-08-29 14:01:50 -05:00
Dustin 8958071edb ci: pyrocufflink: Use pipeline library 2020-08-29 09:12:48 -05:00
Dustin 276ac7e5fb Add rw-root group
Some hosts, such as the Raspberry Pis built using default Fedora images,
do not have proper filesystem separation, but use a single volume for
the entire filesystem.  These hosts cannot have the root filesystem
mounted read-only, since all the writable data are also stored there.

When Jenkins runs configuration policy jobs, it always tries to remount
the root filesystem as read-only on every machine that it configured.
For these hosts with a single volume, this step fails, causing the job
to be marked as failed.  To avoid this, I have added a new group,
*rw-root*; hosts in this group will be omitted from the final remount
step.
2020-08-29 08:53:28 -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 c7e4810abd hosts: Move burp0, taiga0 to offline
These machines are deprecated.  burp1 has replaced burp0. Nextcloud Deck
seems to be just as useful as Taiga.
2020-08-28 21:13:59 -05:00
Dustin 6ebe9b9a20 ci: Always skip tasks tagged "install"
Software should never be installed or updated by the continuous
enforcement jobs.  This can cause unexpected outages or other problems
if applications or libraries unexpectedly.  Everything should already be
installed and in production before continuous enforcement begins, so
skipping install steps should not matter.

Most tasks that install software are tagged with the `install` tag.
When Jenkins runs `ansible-playbook` to apply configuration policy, it
will now skip any task that includes this tag.
2020-07-24 11:56:49 -05:00
Dustin 0f73b09e09 hosts: Add hassdb0.p.b
*hassdb0.pyrocufflink.blue* hosts the PostgreSQL database for Home
Assistant.
2020-07-14 11:38:44 -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 3dcc0aeacd hosts: Add ARM builders to *jenkins-slave* group
The *build1-aarch64.pyrocufflink.blue* and
*build2-armv7hl.pyrocufflink.blue* machines are now configured as
Jenkins nodes.
2020-07-04 14:35:26 -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 f430032d49 homeassistant: Do not apply hass-dhcp
The UniFi Security Gateway now provides DHCP for the Home Assistant
network.  This simplifies management a bit, so I do not have to manage
three DHCP servers.  The USG has firewall rules to prevent Internet
traffic.
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 0a3ff65a8c hosts: Add hass1.p.b
*hass1.pyrocufflink.blue* is the new host for Home Assistant.  I
migrated from using a virtual machine to using a Raspberry Pi to avoid
having to deal with USB passthrough for the Z-Wave USB stick.
2020-07-04 13:49:08 -05:00
Dustin a68e7b04df ci: Update container image to Fedora 32 2020-05-30 12:33:08 -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 a28200e237 pyrocufflink-dhcp: Update MAC address for unifi0
*unifi0.pyrocufflink.blue* is (has been for some time) a virtual
machine.
2020-05-15 10:27:55 -05:00
Dustin 3addbc8ea7 hosts: remove hass0.p.b 2020-05-10 16:30:04 -05:00
Dustin a828bbe56b hosts: remove proxy0.p.b 2020-05-10 16:20:13 -05:00
Dustin e0624a62cf roles/nextcloud: Update to 18.0.2 2020-03-22 11:26:20 -05:00
Dustin 1d0786f46b hosts: Add build2-armv7hl.p.b
*build2-armv7hl.pyrocufflink.blue* is a Raspberry Pi 3 running Fedora
ARM.  It will be used to build software and OS images for other ARM
machines.
2020-03-21 12:42:27 -05:00
Dustin d1a8c1db84 hosts: Add build1-aarch64.p.b
*build1-aarch64* is a Raspberry Pi 3 B+ running Fedora aarch64.  It is
intended to be used to build software and operating system images for
other aarch64 machines.
2020-03-21 12:42:27 -05:00
Dustin aef175b72b ci: Add pipeline for Nextcloud 2020-03-20 11:03:04 -05:00
Dustin 825e6164d9 ci: Add pipeline for Bitwarden 2020-03-19 07:42:25 -05:00
Dustin 744206fd03 ci: Add pipeline for public websites 2020-03-18 11:40:33 -05:00
Dustin eb4139e0be ci lib: Add applyConfigPolicy pipeline function
The Jenkins pipeline definition files are highly redundant.  Each one
implements almost the same stages, with only a few variations.  Whenever
a new pipeline is added, it's copied from the most recent file and
modified.  If any improvements are made to it, they do not usually get
implemented in any of the existing pipelines.

To address this, the `applyConfigPolicy` pipeline library function is
now available.  This function generates the full pipeline for a
particular application, including stages for setup, each individual
playbook, and cleanup.  Using this function, pipeline files can be as
simple as:

    @Library('cfgpol')_

    applyConfigPolicy(
        'gitea',
        [
            'Gitea': [
                'gitea.yml',
            ],
        ]
    )

This will create a pipeline that mounts the root filesystem read-write
on all hosts in the "gitea" group (any Ansible host pattern is allowed),
applies the `gitea.yml` playbook (in a stage named "Gitea"), and then
remounts the filesystems read-only.

Since this "library" is so simple, containing only a single function in
a single file, and since it will not be used by any pipelines outside
this repository, it makes sense to keep it in this repository, instead
of a separate repository as is customary for Jenkins pipeline shared
libraries.
2020-03-18 11:29:35 -05:00
Dustin 583de8d6ea pyrocufflink-dhcp: Reassign 172.30.0.6 to web0.p.b
The TCP ports 80 and 443 are NAT-forwarded by the gateway to 172.30.0.6.
This address was originally occupied by *rprx0.pyrocufflink.blue*, which
operated a reverse proxy for Bitwarden, Gitea, Jenkins, Nextcloud,
OpenVPN, and the public web sites.  Now, *web0.pyrocufflink.blue* is
configured to proxy for those services that it does not directly host
itself, effectively making it a web server, a reverse proxy, and a
forward proxy (for OpenVPN only).  Thus, it must take over this address
in order to receive forwarded traffic from the Internet.
2020-03-17 08:45:34 -05:00
Dustin 66c9581d7b hosts: Decommission rprx0.p.b
*rprx0.pyrocufflink.blue* is no longer in operation.
*web0.pyrocufflink.blue* handles incoming HTTP/HTTPS requests directly,
proxying to Bitwarden, OpenVPN, etc. as needed.
2020-03-17 08:45:34 -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