Deploy Colander on a server with Ansible
This guide shows how to deploy Colander, with Threatr, Mandolin and CyberChef, on a dedicated server using the colander-ansible playbooks. This is the recommended method for a production server.
Colander supports two deployment methods: these Ansible playbooks, and Docker Compose with Colander quick deploy. Choosing how to deploy Colander explains the difference.
Requirementsβ
A dedicated server with at least:
- 4 cores
- 4 GB of RAM
- 500 GB of storage space
The server must have a public IP address and run the latest version of Debian.
In this guide:
- π» marks the commands to run on your laptop, the Ansible control node
- π¦ marks the commands to run on your server
All the commands starting with ansible are run on your laptop.
Get the playbooksβ
Clone the repository on your laptop, not on the server:
git clone https://github.com/PiRogueToolSuite/colander-ansible.git
cd colander-ansible
Regularly pull the updates of the playbooks:
git pull origin main
Set up your serverβ
The latest version of Debian must be installed on your server.
Create a user colander on your server:
useradd -m colander --shell /bin/bash
usermod -aG sudo colander
passwd colander
Set up your laptopβ
Copy your SSH key to the account of the user colander on your server:
ssh-copy-id -i ~/.ssh/my-key colander@[IP address of your server]
In the colander-ansible folder, create a Python 3 virtual environment and install the dependencies:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
ansible-galaxy install -r requirements.yml
Write the inventory fileβ
The inventory file specifies the server on which Colander is deployed. Rename production-example.yml to production.yml and replace:
[IP address of the server]with the IP address of your server[path of your SSH private key]with the path of the SSH private key you copied to the server
Ansible uses this key to connect to your server.
To choose which components are deployed, or to change the memory allocated to Elasticsearch, rename host_vars/production-example.yml to host_vars/production.yml and edit it. See Per-host customization for the available settings.
Install Dockerβ
Install Docker on your server with the playbook install-docker:
ansible-playbook -K -i production.yml playbooks/install-docker.yml
Ansible asks for the BECOME password: the password of the user colander you created. The playbook installs Docker in rootless mode.
Generate the configurationβ
Generate the configuration of Colander. It contains all the secrets of your Colander server, most of them randomly generated:
ansible-playbook -i production.yml playbooks/generate-configuration.yml
The playbook asks for the root domain of your Colander server. You can also pass it on the command line:
ansible-playbook -i production.yml playbooks/generate-configuration.yml --extra-vars "root_domain=my.domain"
This creates the file group_vars/colander/vault. Edit it and fill in:
acme_email: the email address passed to Let's Encryptadmin_name: the full name of the server administratoradmin_email: the email address the crash reports are sent todjango_default_from_email: the email address used to send emailsemail_host: the host of the SMTP serveremail_host_user: the username for the SMTP serveremail_host_password: the password for the SMTP serveremail_port: the port of the SMTP serveremail_use_tls:trueif the SMTP server uses TLS,falseotherwiseemail_use_ssl:trueif the SMTP server uses SSL,falseotherwise
See Configuration vault for an example of a complete file.
Back up the file and encrypt it, as it contains secrets:
ansible-vault encrypt group_vars/colander/vault
Save the password of your vault in your password manager.
Never modify your configuration vault after Colander has been deployed.
Create the DNS recordsβ
Create an A record pointing to the public IP address of your server for each of the following subdomains:
colander.[your domain]threatr.[your domain], only if you deploy Threatrcyberchef.[your domain], only if you deploy CyberCheftraefik.[your domain]
For instance, if your domain is my.domain and the public IP address of your server is 253.127.98.9, the record for Colander is colander.my.domain A 253.127.98.9.
Deploy Colanderβ
The playbook colander configures and deploys Colander on your server:
ansible-playbook -J -i production.yml playbooks/colander.yml
It is equivalent to running:
ansible-playbook -J -i production.yml playbooks/configure-colander.yml
ansible-playbook -J -i production.yml playbooks/deploy-colander.yml
The first deployment can take several minutes. The playbook deploys the whole stack and creates the admin users of Colander and, when enabled, Threatr, with the passwords stored in your configuration vault.
Colander is now available at https://colander.[root domain]/.
Colander updates itself, but it does not update nor upgrade the operating system of the server.