Huginn is a system for building agents that perform automated tasks for you online. They can read the web, watch for events, and take actions on your behalf. Huginn's Agents create and consume events, propagating them along a directed graph. Think of it as a hackable version of IFTTT or Zapier on your own server.
DNS entry for the hostname you intend to use (or a wildcard), pointed to your keepalived IP
Related:
Traefik Forward Auth or Authelia to secure your Traefik-exposed services with an additional layer of authentication
Preparation
Setup data locations
Create the location for the bind-mount of the database, so that it's persistent:
mkdir-p/var/data/huginn/database
Create email address
Strictly speaking, you don't have to integrate Huginn with email. However, since we created our own mailserver stack earlier, it's worth using it to enable emails within Huginn.
cd/var/data/docker-mailserver/
./setup.shemailaddhuginn@huginn.example.commy-password-here
# Setup MX and DKIM if they don't already exist:
./setup.shconfigdkim
catconfig/opendkim/keys/huginn.example.com/mail.txt
Prepare Huginn environment
Create /var/data/config/huginn/huginn.env, and populate with the following variables. Set the "INVITATION_CODE" variable if you want to require users to enter a code to sign up (protects the UI from abuse) (The full list of Huginn environment variables is available here)
# For huginn/huginn - essentialSMTP_DOMAIN=your-domain-here.com
SMTP_USER_NAME=you@gmail.com
SMTP_PASSWORD=somepassword
SMTP_SERVER=your-mailserver-here.com
SMTP_PORT=587SMTP_AUTHENTICATION=plain
SMTP_ENABLE_STARTTLS_AUTO=trueINVITATION_CODE=<setaninvitationcodehere>
POSTGRES_PORT_5432_TCP_ADDR=db
POSTGRES_PORT_5432_TCP_PORT=5432DATABASE_USERNAME=huginn
DATABASE_PASSWORD=<databasepassword>
DATABASE_ADAPTER=postgresql
# Optional extras for huginn/huginn, customize or append based on .env.example lined aboveTWITTER_OAUTH_KEY=TWITTER_OAUTH_SECRET=# For postgres/postgresPOSTGRES_USER=huginn
POSTGRES_PASSWORD=<databasepassword>
BACKUP_NUM_KEEP=7BACKUP_FREQUENCY=1d
Huginn Docker Swarm config
Create a docker swarm config file in docker-compose syntax (v3), something like the example below:
Fast-track with premix! 🚀
"Premix" is a git repository which includes necessary docker-compose and env files for all published recipes. This means that you can launch any recipe with just a git pull and a docker stack deploy 👍.
🚀 Update: Premix now includes an ansible playbook, enabling you to deploy an entire stack + recipes, with a single ansible command! (more here)
Setup unique static subnets for every stack you deploy. This avoids IP/gateway conflicts which can otherwise occur when you're creating/removing stacks a lot. See my list here.
Serving
Launch Huginn stack
Launch the Huginn stack by running docker stack deploy huginn -c <path -to-docker-compose.yml>
Log into your new instance at https://YOUR-FQDN. You'll need to use the "Sign Up" button, and (optionally) enter your invitation code in order to create your account.
Chef's notes 📓
I initially considered putting an oauth proxy in front of Huginn, but since the invitation code logic prevents untrusted access, and since using a proxy would break oauth for features such as Twitter integration, I left it out. ↩
Tip your waiter (sponsor) 👏
Did you receive excellent service? Want to compliment the chef? (..and support development of current and future recipes!) Sponsor me on Github / Ko-Fi / Patreon, or see the contribute page for more (free or paid) ways to say thank you! 👏
Employ your chef (engage) 🤝
Is this too much of a geeky PITA? Do you just want results, stat? I do this for a living - I'm a full-time Kubernetes contractor, providing consulting and engineering expertise to businesses needing short-term, short-notice support in the cloud-native space, including AWS/Azure/GKE, Kubernetes, CI/CD and automation.
Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated.