loopylab

MQTT Dashboard

If you ever develop something with mqtt, you might need a client to send some test messages and view the published messages. To generate a simple dashboard with buttons and subscribers to different topics, a friend of mine and I created a webapp.

The Code can be found on github at https://github.com/DirkHeinke/mqttDashboard and a running demo is here: http://mqttdashboard.dirkheinke.de/

Jekyll, Travis, Docker - permissions denied

After trying to redeploy my blog with travis, the build failed with this message:

[...]
jekyll 3.8.3 | Error:  Permission denied @ dir_s_mkdir - /srv/jekyll/_site

The problem was, that travis set permissions for uid 2000, but the container runs with uid 1000. Adding write permissions to the folder allows jekyll to create a new folder and write the output. My docker run command now looks like this:

docker run --rm --volume=$(pwd):/srv/jekyll jekyll/jekyll /bin/bash -c "chmod a+wx . && jekyll build -V"

WiPy without expansion board

I bought a WiPy 2.0 from pycom and noticed, that the documentation assumes you also bought the expansion board (which I didn’t). The board has some components but most of them are for the SD card support or the LiPo charger. An (older?) version of the board is documented here. What you really need is only some sort of power supply and a USB serial (3.3V). The pinout of the WiPy board is here

I connected a spare ESP8266 programmer to the RX and TX ports and used another USB port for the 5V supply. You can also power the board with 3.3V via the 3.3V pin, but you need at least 500mA (more info).

jekyll, github and travis-ci

The source of this blog is now available at github. Also I’m now using travis-ci to generate the static files and deploy them to my server. Stuff I found out:

travis-ci language

If you use docker to run your commands, the language you specify in the travis.yml file doesn’t really matter.

ssh-key for scp

My deploy script uses scp, so travis needs access to my server. For that, I created a new ssh-key:

ssh-keygen -t rsa -b 4096 -C "Travis CI loopylab" -f travis_loopylab_key

Then added the public part to my server and encrypted the private part with the travis cli:

travis encrypt-file travis_loopylab_key

The newly generated file can be pushed to your repository and no one can readout the key (hopefully).

Now just add the following lines to your travis.yml:

addons:
    ssh_known_hosts: dirkheinke.de
[...]
before_deploy:
    - eval "$(ssh-agent -s)"
    - openssl aes-256-cbc -K ... # use the output of the travis cli
    - chmod 600 /tmp/travis_loopylab_key
    - ssh-add /tmp/travis_loopylab_key

deploy:
    skip_cleanup: true
    provider: script
    script: ./_deploy.sh
    on:
        branch: master

You can find my full travis.yml here

PS: Don’t try to put the private key in a environment variable from travis, because the line breaks are important for ssh.

docker in travis-ci

You can use docker commands in every part of the travis.yml file, even if the documentation only mentions the before_install part.

Ansible Docker - Docker API Error

If you try to run a playbook with the ansible-docker plugin, and you get an error like this

failed: [192.168.2.xxx] => {"changed": false, "failed": true}
msg: Docker API Error: client and server don't have same version (client : 1.19, server: 1.18)

FATAL: all hosts have already failed -- aborting

Solution

You can set the api version to a fixed version. The better way is to use the “auto” feature from docker-py:

- name: start ....
    docker:
      docker_api_version: auto
      image: ....