- Jinja 48.6%
- Python 27.9%
- Shell 18.8%
- PHP 4.3%
- HTML 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| ansible | ||
| s | ||
| .gitignore | ||
| instructions | ||
| README.md | ||
Fleet Management
This controls all of the fleet management software to be able to:
- Bring up new hosts of a certain type
- Perform management operations on a certain host/type
Installing Ansible
Per the instructions here http://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#latest-releases-via-apt-ubuntu
sudo apt-get update
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
Using ansible
Use s/ansible-playbook to run ansible-playbook, you'll first need to
provide the fleet management encryption password, and after it will ask you to
delete the locally decrypted files. Unless there was an error this should be
perfectly safe.
Using ansible version ansible-playbook 2.9.12
Configuration file
- Avoid bullshit
Adding new hosts
Note: opensmtpd is not installed from ubuntu. The version supplied by Ubuntu (6.8.0p2) has a fairly serious bug where mail cannot be received from all servers. I've manually install opensmtpd-7.4.0p1 from source (./configure; make; sudo make install).
The following manual steps may be needed:
- symlink: /usr/lib/ssl/cert.pem -> /etc/ssl/certs/ca-certificates.crt
- Add to inventory.yml to the
ubuntu_needs_bootstraprole for bootstrapping - Run ansible/playbooks/bootstrap-new-hosts.yml
- Manually set a password for the
sufianuser (for sudo) - Change inventory.yml to add roles
- Run ansible/playbooks/update-hosts.yml
- Run various deploy scripts
Note:
- For new hosts, you need to
sudo certbot run -d ${DOMAIN}for each domain - For new hosts, you need to generate a new tarsnap keypair:
sudo tarsnap-keygen --keyfile /root/tarsnap.key --user sufian@abstract.properties --machine host-NNNN.abstract.propertiesand place (encrypted) asansible/roles/common/files/host-NNNN.abstract.properties.tarsnap.key.aes - For new hosts, you need to install nodejs apt settings:
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -(yes seriously, fuck this, what the fuck)sudo apt-get install -y nodejs- Verify node 16 is installed: node --version
- Enable corepack:
sudo corepack enable - Update yarn:
yarn corepack prepare yarn@stable --activate
Quarterly maintenance
- Generate new ssh authorized keys for: ansible/roles/common/files/{ansible_config_authorized_keys,sufian_authorized_keys}
- via:
ssh-keygen -t ed25519 -a 100 -f out.ed25519.key - Don't forget to update github / other places that use this public key
- Update TLS certs for host-0004.abstract.properties
- On host:
sudo certbot --nginx* Note: the certificates may already have been renewed. Check via:- sudo cat /etc/letsencrypt/live/abstract.properties/cert.pem | openssl x509 -inform pem -noout -enddate
- Copy files from
host-0004.abstract.properties:"/etc/letsencrypt/live/${DOMAIN}/*"to the appropriate encrypted destination inansible/roles/static_web/files/certs/${DOMAIN}/*: *rsync -avh --rsync-path="sudo rsync" --copy-links 'ansible-client@host-0004.abstract.properties:/etc/letsencrypt/live/' ansible/roles/static_web/files/certs - Encrypt the new files:
find ansible/roles/static_web -type f -name '*.pem' | xargs s/encrypt - Update TLS certs for host-0005.abstract.properties
- On host:
sudo certbot --nginx* Note: the certificates may already have been renewed. Check via:- sudo cat /etc/letsencrypt/live/abstract.properties/cert.pem | openssl x509 -inform pem -noout -enddate
- Copy files from
host-0005.abstract.properties:"/etc/letsencrypt/live/${DOMAIN}/*"to the appropriate encrypted destination inansible/roles/app_shshararee/files/certs/${DOMAIN}/*: *rsync -avh --rsync-path="sudo rsync" --copy-links 'ansible-client@host-0005.abstract.properties:/etc/letsencrypt/live/' ansible/roles/app_shshararee/files/certs - Encrypt the new files:
find ansible/roles/app_shshararee -type f -name '*.pem' | xargs s/encrypt - Update hosts:
s/ansible-playbook ansible/playbooks/update-hosts.yml - Verify cert expiry:
/etc/cron.daily/check_cert_expiry --no-send - Check if kernel needs reboot, reboot if needed
Backups
tarsnap is configured and installed for backups.
Currently, all git repos in /srv/git are shallowly backed up on a weekly basis via cron.weekly.
- By default, only
HEADis backed up. - Add a
periodic-backup-refsfile if you want multiple refs backed up
To restore, use the tarsnap key to check the <hostname>:git:<datestring> archive.
Yearly, the tarsnap debian signing key expires, this will cause the tarsnap key to fail:
- Check the instructions here: https://www.tarsnap.com/pkg-deb.html
- The signing key is stored here: ansible/roles/common/files/tarsnap-deb-packaging-key.asc
Upgrading pleroma
Easy instructions (new)
- Go to the pleroma release directory:
cd /opt/pleroma/release - Safety -- turn it off:
sudo service pleroma stop - Download the new version:
sudo -u pleroma ./bin/pleroma_ctl update - Migrate the db:
sudo -u pleroma ./bin/pleroma_ctl migrate - (optional) Vacuum the db:
sudo -u pleroma psql pleroma-- runVACUUM ANALYZE - Safety -- turn it back on:
sudo service pleroma start
Hard instructions (old)
- Get a new version of pleroma: sudo -u pleroma curl 'https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=amd64' -o /opt/pleroma/pleroma-2023-02-11.zip
- Stop the service and ensure it's down: sudo sysctl stop pleroma
- Move prior release in case things go south sudo mv /opt/ple;roma/release /opt/pleroma/release-prev
- Unzip new version (within /opt/pleroma) sudo -u pleroma unzip pleroma-2023-02-11.zip
- Run database migrations (if any) cd /opt/pleroma/release sudo -u pleroma bin/pleroma_ctl migrate
- Start the service again sudo sysctl start pleroma
- Put the zip in the right place, fix ansible files
Upgrading pleroma frontend (pleroma-fe)
The frontend is installed as static files in /var/lib/pleroma/static
The "dist" directory of pleroma-fe is synced to that folder.
Updates involve building pleroma-fe and syncing the dist directory over.
Monitoring services / healthchecks
Write some cron jobs that run every minute / hour; and if fail post via Slack app hooks.
goaccess --log-format='%dT%t\t%h\t%^\t%^\t%^\t%u\t%m\t%v\t%U\t%s\t%b\t' --date-format='%Y-%m-%d' --time-format='%H:%M:%S%z'