#huginn

Extremely sorry for the breakdown in service. I use #Huginn to relay tweets and it seems the instance has died for some reason. Will check and ensure proper monitoring is added. Service will resume shortly once Huginn is booted.

Real time WW2

Sunday project: Huginn, Docker & Ansible

Some time ago I set up a #Twitter account posting #WWII "as it happened" events to #Socialhome (see here). This was accomplished using Zapier that reads the tweets and then POST's to the Socialhome API.

All that worked great and #Zapier is really nice. Except it's limited to 100 events per month on the free tier and this seems wasn't enough for the WWII tweets coming in. Zapier paid plans are from $20/mo which is way too much just to replicate some tweets.

At first I thought about making my own app to do all this but then I remembered running into Huginn, which I have been wanting to install anyway. It's basically a self-hosted #IFTT or Zapier, but allowing for even more complex stuff like unlimited chaining of events.

Docker + Ansible

I'm pretty new to #Docker but eventually I want to dockerize more of my apps. So of course I was happy to see #Huginn has a Docker image, allowing me to not have to muck about with any more #RoR apps. I use #Ansible for pretty much everything, so it made sense to build a playbook to deploy the app in a Docker container.

Luckily (or thanks to the fantastic Ansible team that is!), maintaining Docker containers with Ansible is as easy as doing anything else with it.

I chose to keep the web server out of the containers to use my standard #LetsEncrypt role for getting SSL on top. This made the role very simple, having only to 1) fetch SSL cert, 2) set up Apache to proxy and 3) push up a container.

The docker_container Ansible module call is basically just this:

 ---
 - docker_container:
   name: huginn
   image: huginn/huginn
   volumes:
     - "{{ huginn_db_volume_mount }}:/var/lib/mysql"
   env:
     APP_SECRET_TOKEN: "{{ huginn_secret }}"
     DOMAIN: "{{ huginn_domain }}"
     FORCE_SSL: "{{ huginn_https}}"
     INVITATION_CODE: "{{ huginn_invitation_code }}"
     MAIL_FROM_ADDRESS: "{{ huginn_mail_from }}"
     RAILS_ENV: production
     SMTP_DOMAIN: "{{ huginn_smtp_domain }}"
     SMTP_PASSWORD: "{{ huginn_smtp_password }}"
     SMTP_PORT: "{{ huginn_smtp_port }}"
     SMTP_SERVER: "{{ huginn_smtp_server }}"
     SMTP_USER_NAME: "{{ huginn_smtp_username }}"
     TWITTER_OAUTH_KEY: "{{ huginn_twitter_key }}"
     TWITTER_OAUTH_SECRET: "{{ huginn_twitter_secret }}"
   register: _docker_huginn

The container IP is then picked up from _docker_huginn by Apache to do the proxying.

The playbook itself, without any extra customization is pretty much here:

 ---
 - hosts: myhost
   become: yes
   become_user: root

   vars:
     letsencrypt_email: youremail@example.com
     huginn_domain: huginn.example.com
     huginn_invitation_code: changeme!
     huginn_secret: changeme!

   roles:
     - huginn

The result is the ansible-huginn role. Tested on #Ubuntu 14.04. Right now a bit limited in terms of configuration that can be passed in. Will expand as necessary.

Fun Huginn stuff

Some initial things I want to do is to use the chaining to make the tweet replicating not embed the tweet, but instead rip out the text + media and create a normal post instead. That should make for cleaner streams with less Twitter JS firing off.

Any tips on fun stuff to do with Huginn?

huginn/huginn
huginn - Create agents that monitor and act on your behalf. Your agents are standing by!

Jason Robinson