Aaron LI
Created: 2018-02-14
Ansible: 2.7.7 (Python 3.7.3)
An Ansible playbook to manage a very small (read 512MB RAM) VPS to self-host various services including:
- DNS (NSD for authoritative DNS service)
- Email (Postfix, Dovecot)
- Web (Nginx, acme-client for Let's Encrypt certificates)
- CalDAV/CardDAV (Radicale with uWSGI)
- Git (Web interface via cgit with uWSGI)
- IRC Bouncer (ZNC)
-
bootstrap.yml: Bootstrap the remote host (e.g., a VPS) after installing DragonFly BSD.NOTE:
- Use the
bootstrap.shscript instead. - The new host should be configured that allow
rootssh into it using a password. (This will be disabled during the bootstrap.)
- Use the
-
deploy.yml: The main playbook that deploys services on the target host.
-
ansible.cfgAnsible configuration file -
inventory.ymlRemote host specifications -
group_vars/all/vars.ymlVariables for hosts in theallgroup, i.e., all hosts -
group_vars/all/vault.ymlEncrypted variables that will merged into the abovevars.ymlupon Ansible playing the playbook. -
host_vars/vultrVariables specific to this host.
-
bootstrapOnly used in thebootstrap.ymlplaybook to bootstrap a newly installed DragonFly BSD host. -
basicBasic settings, includes:- Tune basic services in
/etc/rc.conf - Set some system tunables in
/boot/loader.conf - Enable
/var/log/console.login syslog - Tune csh/tcsh
- Tweak pkg and install basic packages
- Tune basic services in
-
security- Setup PF firewall
- Enable
sshlockout
-
dns -
web -
mail -
git- Self-host Git repositories
- Web interface via cgit
- Also manage and deploy the static resources of cgit via a Git repo
-
shadowsocksSetup ShadowSocks-libev for a useful proxy. -
zncSetup ZNC IRC bouncer connecting to channel#dragonflybsdon EFNet. -
radicaleSetup Radicale as a lightweight CalDAV/CardDAV server for personal calendars and contacts. Served via Nginx and uWSGI.
filter_plugins/Custom template filters
-
Bootstrap the remote host:
$ sh bootstrap.shNOTE: The remote host should be configured to allow SSH
rootlogin, which will be disabled later to enhance security. -
Test host connection:
$ ansible vultr -m ping -
List tasks:
$ ansible-playbook deploy.yml -v --list-tasks -
Run (check only but don't make changes) the whole playbook:
$ ansible-playbook deploy.yml -vD [--check] -
Run the playbook from a specific task:
$ ansible-playbook deploy.yml -vD --step --start-at-task="..." -
Run the tasks with specific tags:
$ ansible-playbook deploy.yml -vD --tags="..." -
View and edit the encrypted variables:
$ ansible-vault view group_vars/all/vault.yml $ ansible-vault edit group_vars/all/vault.yml
- Securing a Server with Ansible https://ryaneschinger.com/blog/securing-a-server-with-ansible/