Becoming an admin¶
A clone of this repository is not enough to run a deployment. The repository is the same for every organisation; what makes it one particular deployment lives in files that git ignores, on the host, and in the cloud project. This chapter lists what a second admin needs to act without the first one, for an update (see Keeping a deployment up to date), a reboot or a bad day. An existing admin hands over each part.
SSH access to the host¶
Ansible and the admins log in as root, with a key only: the sshd role
switches password logins off and allows root to log in with a key and nothing
else. The new admin sends their public key, and an existing admin appends
it to /root/.ssh/authorized_keys on the host:
ssh root@<host> 'cat >> /root/.ssh/authorized_keys' < new-admin.pub
The new admin then checks that they can log in. The address is in
ansible/hosts.ini.
Put the key into tf/ssh-keys/<name>.pub of the deployment’s clone as well,
but do not expect Terraform to put it on the server. hcloud_server ignores
changes to ssh_keys, because Hetzner only injects keys when a server is
built (see Terraform). The next tofu apply adds the key to the
project, and a rebuilt server gets every key in that directory. To take
access away again, remove the line from authorized_keys on the host;
removing the file from tf/ssh-keys/ alone changes nothing on the host.
The repository¶
The new admin needs a clone with write access to the shared remote, and the tools the playbook runs with:
git clone <remote> <directory>
cd <directory>
git submodule update --init --recursive
python3 -m venv ~/.venvs/ae
. ~/.venvs/ae/bin/activate
pip install -r docs/requirements.txt
cd ansible
make python-deps
make collections
docs/requirements.txt is there because the documentation role builds
this documentation on the control machine during a full run, and the run
fails at that role without sphinx-build.
The commit that runs on the host has to be on the shared remote. Every template is rendered from the clone the playbook runs from, versions included, so a clone that is behind what is deployed rolls the host back on its next run. Push what you deploy, and pull before you deploy.
On a host where ae_website_source is set, the website role takes the
site’s source from a checkout on the control machine instead of cloning its
repository on the server. Whoever runs that role needs the checkout as well.
Without it, the server clones ae_website_repository at
ae_website_version on every run, so what goes live is what has been pushed
there. A private repository needs a deploy token in host_vars
(ae_website_repository_user, ae_website_repository_token).
The deployment’s own files¶
Everything that belongs to one deployment is in .gitignore and exists only
in the clones of the people who run it:
ansible/hosts.iniThe inventory.
tofu applywrites it fromtf/templates/hosts.ini.tpl; it holds one line per host.ansible/host_vars/<host>.ymlEvery value that overrides a role default for this deployment: the domains,
ae_disabled_roles, mounts, the backup repository, branding,ae_grafana_alert_addresses. The host is calledcompact-1in every deployment so far.ansible/<host>/The secrets the playbook generated: every password, the borg passphrase and repository key, the DKIM keys. A run without them does not fail. The password lookup creates a new secret for every file it does not find, in check mode too, and the roles write the new values into the services’ configuration, while the host keeps the old ones where it stored them: the LDAP and database passwords are podman secrets that a run does not overwrite, and the borg repository stays encrypted with the old passphrase. Do not run the playbook against a live host, not even with
--check, before this directory is in place. Every playbook that runs roles importscheck-secrets.ymlfirst, which stops the run when the directory holds none of the secrets; it does not notice a single missing file. Only a deployment’s very first run passes-e ae_first_run=true.ansible/files/<host>/Files that
host_varsrefer to, such as the logo theseamrole shows.tf/terraform.tfstate,tf/*.auto.tfvars,tf/ssh-keys/,tf/dkim.tfOnly needed by whoever runs
tofu; see Terraform. The state is the one to be careful with: Terraform knows the server only through it, and with copies in two places only one of them is current after an apply.
These files do not travel through the repository. Keep them in a private
repository of their own, encrypted with sops and
age: every file at the path it has in a
clone, encrypted for one age key per admin and for a recovery key kept on
paper. Each admin decrypts the files into their clone, where .gitignore
keeps them out of git, and encrypts their changes back. That repository’s
README says how, and holds what is particular to the deployment: where the
repository lives, whose keys it lists, and who keeps the paper key.
Whatever carries the files has to handle three things:
New secrets: a run creates one when a role runs for the first time,
--checkincluded. The new file has to reach the other admins before their next run, or that run creates a different one.Two admins changing the same file.
The whole set: before any run, the clone has to hold every file, not just some of them.
check-secrets.ymlcatches a clone without the directory, but not a single missing file.
The Terraform state stays an exception: only one admin runs tofu, and
every other copy is a backup.
A new admin sends the public half of their age key. An existing admin adds it and encrypts every file again for the new list of keys. Taking an admin out works the same way without their key, and the secrets they could use from outside have to be changed: the old encrypted files stay in the repository’s history, and their key still opens them.
The cloud project¶
The server, its firewalls and the DNS zone live in a Hetzner Cloud project.
An admin needs to be a member of it for what Ansible cannot do: taking a
snapshot before a risky change (Upgrading starts with one), restoring
one of the daily backups Hetzner takes of the server (server_backups in
tf/variables.tf), the web console when SSH does not answer, and the
rescue system. Invite the new admin to the project in the Hetzner Console. If
they run tofu as well, they create an API token of their own there
instead of using somebody else’s.
Alerts and accounts¶
Grafana sends every alert to the addresses in ae_grafana_alert_addresses
in host_vars/<host>.yml. Add the new admin’s address and run the role:
ansible-playbook -i hosts.ini setup.yml --tags grafana </dev/null
Use an address that accepts mail. Grafana counts one rejected address as a failed notification and tries again every five minutes, so every other address in the list then gets each alert every five minutes.
The new admin also needs an account in the directory: in the admin group
to log in to Grafana and administer Mailman, in lldap_admin to manage
users (see Administration). To receive the mail for postmaster@ and
abuse@, add the uid to ae_lldap_mail_operators in host_vars and
run the lldap role; the account has to be in the mail group as well.
A first run¶
Before the new admin needs any of this alone, they run the playbook once in check mode from their own clone, with the deployment’s files in place:
ansible-playbook -i hosts.ini setup.yml --check --diff --tags caddy </dev/null
Apart from the image pull, which always reports a change in check mode, and the restart it notifies, the run has to come out without changes. A template that would change means the clone or the deployment’s files differ from what the last run used; find out why before running anything for real. Then do the same for the roles the new admin is going to work with.