Thomas Buck 046c03aa3a matrix.org was hacked and made some changes to their packet infrastracture. Changed URLs. | 5 years ago | |
---|---|---|
filter_plugins | 5 years ago | |
group_vars | 5 years ago | |
roles | 5 years ago | |
.gitignore | 5 years ago | |
CONTRIBUTING.md | 5 years ago | |
LICENSE.md | 9 years ago | |
README.md | 5 years ago | |
hosts | 8 years ago | |
requirements.txt | 5 years ago | |
site.yml | 5 years ago |
Sovereign is a set of Ansible playbooks that you can use to build and maintain your own personal cloud based entirely on open source software, so you’re in control.
If you’ve never used Ansible before, you might find these playbooks useful to learn from, since they show off a fair bit of what the tool can do.
The original author’s background and motivations might be of interest. tl;dr: frustrations with Google Apps and concerns about privacy and long-term support.
Sovereign offers useful cloud services while being reasonably secure and low-maintenance. Use it to set up your server, SSH in every couple weeks, but mostly forget about it.
What do you get if you point Sovereign at a server? All kinds of good stuff!
iot.domain/mqtt
.Don’t want one or more of the above services? Comment out the relevant role in site.yml
.
Or get more granular and comment out the associated include:
directive in one of the playbooks.
You do not need to acquire an SSL certificate. The SSL certificates you need will be obtained from Let’s Encrypt automatically when you deploy your server.
The following steps are done on the remote server by ssh
ing into it and running these commands.
apt-get install sudo python
For goodness sake, change the root password:
passwd
Create a user account for Ansible to do its thing through:
useradd deploy
passwd deploy
mkdir /home/deploy
Authorize your ssh key if you want passwordless ssh login (optional):
mkdir /home/deploy/.ssh
chmod 700 /home/deploy/.ssh
nano /home/deploy/.ssh/authorized_keys
chmod 400 /home/deploy/.ssh/authorized_keys
chown deploy:deploy /home/deploy -R
echo 'deploy ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/deploy
Your new account will be automatically set up for passwordless sudo
.
Or you can just add your deploy
user to the sudo group.
adduser deploy sudo
Ansible (the tool setting up your server) runs locally on your computer and sends commands to the remote server.
Download this repository somewhere on your machine, either through Clone or Download > Download ZIP
above, wget
, or git
as below.
Also install the dependencies for password generation as well as ansible itself.
git clone https://github.com/xythobuz/sovereign.git
cd sovereign
sudo pip install -r ./requirements.txt
Modify the settings in the group_vars/sovereign
folder to your liking.
If you want to see how they’re used in context, just search for the corresponding string.
All of the variables in group_vars/sovereign
must be set for sovereign to function.
Finally, replace the host.example.net
in the file hosts
.
If your SSH daemon listens on a non-standard port, add a colon and the port number after the IP address.
In that case you also need to add your custom port to the task Set firewall rules for web traffic and SSH
in the file roles/common/tasks/ufw.yml
.
If you’ve just bought a new domain name, point it at Linode’s DNS Manager or similar. Most VPS services (and even some domain registrars) offer a managed DNS service that you can use for this at no charge. If you’re using an existing domain that’s already managed elsewhere, you can probably just modify a few records.
Create A
or CNAME
records which point to your server’s IP address:
example.com
mail.example.com
www.example.com
(for Web hosting)autoconfig.example.com
(for email client automatic configuration)fathom.example.com
(for web stats)news.example.com
(for Selfoss)cloud.example.com
(for NextCloud)git.example.com
(for gitea)status.example.com
(for monit)matrix.example.com
(for riot)social.example.com
(for mastodon)comments.example.com
(for commento)iot.example.com
(for grafana)First, make sure you’ve got Ansible installed. This should already be done by running the pip requirements.txt from above.
To run the whole dang thing:
ansible-playbook -i ./hosts --ask-sudo-pass site.yml
If you chose to make a passwordless sudo deploy user, you can omit the --ask-sudo-pass
argument.
To run just one or more piece, use tags. I try to tag all my includes for easy isolated development. For example, to focus in on your firewall setup:
ansible-playbook -i ./hosts --tags=ufw site.yml
You might find that it fails at one point or another. This is probably because something needs to be done manually, usually because there’s no good way of automating it, or because something changed in the upstream packages or you’re not using Debian 9. Fortunately, all the tasks are clearly named so you should be able to find out where it stopped. I’ve tried to add comments where manual intervention is necessary. In the best case scenario, no manual steps should be needed, everything is done via the sovereign config vars.
The dependencies
tag just installs dependencies, performing no other operations.
The tasks associated with the dependencies
tag do not rely on the user-provided settings that live in group_vars/sovereign
.
Running the playbook with the dependencies
tag is particularly convenient for working with Docker images.
Create an MX
record for example.com
which assigns mail.example.com
as the domain’s mail server.
To ensure your emails pass DKIM checks you need to add a txt
record.
The name field will be mail._domainkey.EXAMPLE.COM.
The value field contains the public key used by DKIM.
The exact value needed can be found in the file /var/lib/rspamd/dkim/EXAMPLE.COM.mail.txt
.
For DMARC you’ll also need to add a txt
record.
The name field should be _dmarc.EXAMPLE.COM
and the value should be v=DMARC1; p=reject
.
We will also add a txt
record for SPF. This is now legacy, but some providers need it, so we provide an empty policy.
For my DNS provider, that zonefile looks like this:
@ IN MX 10 mail
@ IN TXT "v=spf1 a:mail.example.com ?all"
_dmarc IN TXT "v=DMARC1; p=reject;"
mail._domainkey IN TXT "v=DKIM1; k=rsa; p=INSERT_PUBLIC_KEY_HERE"
Correctly set up reverse DNS for your server and make sure to validate that it’s all working, for example by sending an email to check-auth@verifier.port25.com and reviewing the report that will be emailed back to you.
Sign in to the ZNC web interface and set things up to your liking. It isn’t exposed through the firewall, so you must first set up an SSH tunnel:
ssh deploy@example.com -L 6643:localhost:6643
Then proceed to http://localhost:6643 in your web browser. The same goes for the RSpamD web interface on port 11334.