Aller au contenu principal

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:

πŸ’» Clone the playbooks on your laptop
git clone https://github.com/PiRogueToolSuite/colander-ansible.git
cd colander-ansible

Regularly pull the updates of the playbooks:

πŸ’» Pull new updates
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:

πŸ“¦ 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:

πŸ’» Copy your SSH key to the 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:

πŸ’» Set up the Ansible environment
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:

πŸ’» Install Docker on your server
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:

πŸ’» Generate the configuration of Colander
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:

πŸ’» Generate the configuration of Colander
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 Encrypt
  • admin_name: the full name of the server administrator
  • admin_email: the email address the crash reports are sent to
  • django_default_from_email: the email address used to send emails
  • email_host: the host of the SMTP server
  • email_host_user: the username for the SMTP server
  • email_host_password: the password for the SMTP server
  • email_port: the port of the SMTP server
  • email_use_tls: true if the SMTP server uses TLS, false otherwise
  • email_use_ssl: true if the SMTP server uses SSL, false otherwise

See Configuration vault for an example of a complete file.

Back up the file and encrypt it, as it contains secrets:

πŸ’» Encrypt the file that contains the secrets
ansible-vault encrypt group_vars/colander/vault

Save the password of your vault in your password manager.

Immutable configuration

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 Threatr
  • cyberchef.[your domain], only if you deploy CyberChef
  • traefik.[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:

πŸ’» Configure and deploy Colander
ansible-playbook -J -i production.yml playbooks/colander.yml

It is equivalent to running:

πŸ’» Configure and deploy Colander in 2 steps
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.

Next steps​