Skip to content

A set of Ansible playbooks to build and maintain your own private cloud: email, calendar, contacts, file sync, IRC bouncer, VPN, and more.

Notifications You must be signed in to change notification settings

danhallock/sovereign

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Sovereign is a set of Ansible playbooks that you can use to build and maintain your own personal cloud (I know I know). It’s based entirely on open source software, so you’re in control.

If you’ve never used Ansible before, you a) are in for a treat and b) might find these playbooks useful to learn from, since they show off a fair bit of what the tool can do.

Background/Motivations

I had been a paying Google Apps customer for personal and corporate use since the service was in beta. Until several weeks ago, that is. I was about to set up another Google Apps account for a new project when I stopped to consider what I would be funding with my USD $50 per user per year:

  1. A seriously questionable privacy track record.
  2. A dwindling commitment to open standards.
  3. A lack of long-term commitment to products.
  4. Development of Google+: a cynical and unimaginative Facebook ripoff that’s intruding into progressively more Google products.

To each her/his own, but personally I saw little reason to continue participating in the Google ecosystem. It had been years since I last ran my own server for email and such, but it’s only gotten cheaper and easier to do so. Plus, none of the commercial alternatives I looked at provided all the services I was looking for.

Rather than writing up a long and hard-to-follow set of instructions, I decided to share my server setup in a format that you can more or less just clone, configure, and run. Ansible seemed like the most appropriate way to do that: it’s simple, straightforward, and easy to pick up.

I’ve been using this setup for about a month now and it’s been great. It’s also replaced a couple of non-Google services I used, saving me money and making me feel like I’ve got a little more privacy.

The backbone of this was inspired by this post by Drew Crawford. Unlike him, my goal is not “NSA-proofing” my email, just providing a reasonable alternative to Google Apps that isn’t wildly insecure. My view is that if the NSA or any other motivated party really wants to pwn me, they’re gonna, simple as that, no matter where I host my email.

Services Provided

What do you get if you point this thing at a VPS? All kinds of good stuff!

  • IMAP over SSL via Dovecot, complete with full text search provided by Solr.
  • SMTP over SSL via Postfix, including a nice set of DNSBLs to discard spam before it ever hits your filters.
  • Virtual domains for your email, backed by MySQL.
  • Secure on-disk storage for email and more via EncFS.
  • Spam fighting via DSPAM and Postgrey.
  • Mail server verification via OpenDKIM, so folks know you’re legit.
  • CalDAV and CardDAV to keep your calendars and contacts in sync, via ownCloud.
  • Your own private Dropbox, also via ownCloud.
  • Your own VPN server via OpenVPN.
  • An IRC bouncer via ZNC.
  • Monit to keep everything running smoothly (and alert you when it’s not).
  • Web hosting (ex: for your blog) via Apache.
  • Firewall management via ferm.
  • Intrusion prevention via fail2ban and rootkit detection via rkhunter.
  • Nightly backups to Tarsnap.
  • A bunch of nice-to-have tools like mosh and htop that make life with a server a little easier.

No setup is perfect, but the general idea is to provide a bunch of useful services while being reasonably secure and low-maintenance. Set it up, SSH in every couple weeks, but mostly forget about it.

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.

Usage

What You’ll Need

  1. A VPS (or bare-metal server if you wanna ball hard). My VPS is hosted at Linode. You’ll probably want at least 512 MB of RAM between Apache, Solr, and MySQL. Mine has 1024.
  2. Debian 7 or an equivalent Linux distribution. (You can use whatever distro you want, but deviating from Debian will require more tweaks to the playbooks. See Ansible’s different packaging modules.)
  3. A wildcard SSL certificate. I bought one. You could self-sign if you wanna save money.
  4. A Tarsnap account with some credit in it. You could comment this out if you want to use a different backup service. I pay for backups at Linode in addition to the Tarsnap nightlies because you can never be too sure.

Manual Steps

This does a lot for you automatically but there’s still some stuff you have to do by hand.

  1. Set up EncFS as per these instructions.
  2. Create a user account for Ansible to do its thing through. This account should be set up for passwordless sudo.
  3. Put your Tarsnap key in roles/common/files/root_tarsnap.key.
  4. Put your SSL certificate’s components in the respective files that start with wildcard_ca in roles/common/files, and a combined version in roles/ircbouncer/files/etc_ssl_znc-combined.pem.
  5. Set up SPF and reverse DNS as per the inspirational post. Make sure to validate that it’s all working, for example by sending an email to [email protected] and reviewing the report that will be emailed back to you.
  6. Sign in to the ZNC web interface and set things up to your liking.
  7. You should probably disable remote root login and password-based logins in /etc/ssh/sshd_config but that’s up to you.

Now, the time-consuming part: grep through the files for the string TODO and replace as necessary. You’ll probably want to check out all the files in the respective vars/ sub-directories in each playbook directory.

Running It

First, make sure you’ve got Ansible installed.

To run the whole dang thing:

ansible-playbook -i ./hosts site.yml

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=ferm 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. 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. OpenVPN in particular requires a bunch of manual command line stuff to get running.

How I Use It

First, I moved all my email off Google with larch. It worked like a charm. Calendars and contacts were even easier: just export and then import the standard formats with your clients of choice; no issues with Calendar.app and Contacts.app.

I use this setup from my Mac like this:

  • I read email in Airmail.
  • I manage my calendar and contacts via the Apple-provided Calendar.app and Contacts.app. See ownCloud’s docs to get it set up.
  • I connect to the VPS via Viscosity. It has some dumb DNS bug right now so I have to point my machine to OpenDNS in order to resolve names. Despite that, it’s better than the alternative.
  • I connect to the IRC bouncer with Textual.
  • I run the ownCloud sync client for Dropbox-like file sync.
  • I manage my blog and other sites with Jekyll locally, then push the resulting builds up to the server via rsync over SSH.

… and from my iPhone like this:

  • I read email in the Apple-provided Mail app and check it quickly in Triage.
  • I manage my calendar and contacts with the built-in apps. Boring, effective. See the ownCloud docs for setup instructions.
  • I access files stored in my ownCloud instance via their app.
  • I connect to my IRC bouncer with Palaver.

Contributing

If you improve one of the provided playbooks or add an exciting new one, send a pull request. Everyone benefits.

License

Original content is GPLv3, same as Ansible. All files and templates based on third-party software should be considered under their respective licenses.

About

A set of Ansible playbooks to build and maintain your own private cloud: email, calendar, contacts, file sync, IRC bouncer, VPN, and more.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published