ads' corner

Blog website crawlers and bots in Apache2

Found a couple more bots crawling my website, and from the look at online resources it seems I catched a few of the bad guys. Crawlers which ignore the robots.txt standard, and just crawl a website for content.

Decided to do something against it, and added a filter in Apache2.


Use namespace as global variable in Ansible Jinja templates

A simple task, or so I thought: in a Jinja template keep track of the number of items in a loop. And then use that count afterwards.

Disclaimer: the number of items is not equal the number of times the loop runs, so I can’t use the loop variables.

Turns out that Jinja has other opinions, and variables inside a loop are all local. When a variable is changed inside the loop, the scope of the variable stays local, and once the loop ends the original value of the variable is restored. That’s even true for variables which are created outside the loop.


Install openHAB2 bindings using Ansible

Recently I started looking into Home Automation, using a Raspberry Pi and the openHAB as platform. The website provides ready-to-go images based on Debian, named openHABian. Me being me, I decided to install the image, let it boot up for the first time, and then take it from there using Ansible as automation tool. That’s a bit more effort in the beginning, but ensures that I can always just wipe the SDcard, and start over from the beginning. Especially useful if I screw up at some point during testing.