Blog by Daniel Hauck. Sysadmin, Developer, Blogger.


mongoDB training virtual machine with ansible


Today I created a virtual machine for mongoDB. It’s a long time since I worked last time with it. So I wanted a generic machine that I can start, stop or destroy without the need to reinstall it everytime by hand. Sounds like vagrant and ansible 😉

Get our hands dirty

As mentioned, I will use a Vagrant base image of Ubuntu 14.04 and provision it with ansible to install and configure mongoDB. Since I don’t like to use vagrant portmapping for all port that I may be using, I like to use the vagrant plugin ‘vagrant-hostsupdater’.

  1. Install vagrant from here.
    For example on debian or ubuntu:
  2. Install vagrants hostsupdater plugin:
  3. Install git and ansible on your machine
  4. Clone my git repository and change to the directory:
  5. Just run the vagrant machine
  6. That’s it!

After the startup and the provisioning of the vagrant machine finished you either can ssh into the vagrant machine to play with your mongodb instance

or connect directly to mongodb with

That’s the cool thing about the hostsupdater plugin, you can interact with the machine just like a real host, just give it a hostname in the Vagrantfile.


So after a couple of minutes you are up and running and can begin your journey with a great noSQL database management system.

Don’t forget to follow me on twitter or subscribe to the newsletter on the left site to recieve the latest posts. Of course you can give me a few stars on github 🙂


Have fun!

Think Like A Dev, Op!

Grüß Gott and a nice evening!

Today I am going to talk about this thing, everybody heard about, it’s ‘DEVOPS’. No, I’ll not. At least a bit.

Devops means a melt between the developers and the ops guys. We should use the same processes, tools and stuff.

In my honest opinion, the developers do the ‘melt’ better than us(the evil ops). They automate their minification and unit tests and all these helpful things. The learned their lessons.

But we(the ops) often miss to learn from them. How often I see creepy(really creepy) server configs, no matter if apache, nginx, icinga, ansible, whatever. Why the most of us don’t stick to some kind of coding standard? Why the f… we don’t use CI tools like the devs do? Why don’t we use lint-tools like devs do?

It ain’t that hard to define a standard about using tabs or spaces in your icinga config.
It ain’t that hard to define a vim command that lints your ansible config BEFORE writing.
It ain’t that hard to configure your CI-server(i.e. jenkins) to clone your icinga-repo and do a simple config test before syncing it to production.

It’s not just about checking the config for errors, it is also about collaboration. I hate it, when someone asks me to take a look at his config file, why it’s not working and I recognize 30 different indentation styles or lines about 300 chars. It will take at least the double amount of time to find the small little error, the missed semicolon or similar, only because of a bad style. I have to cite PanadeEdu on twitter, he puts it in a nutshell:

So what’s the point? We have to do our homework too!

In the next few posts, I’ll bring some topics that will help you achieving this goal.
They contain:
– Code Quality for Sysadmins, Operations
– CI/CD for Sysadmins, Operation
– And many more!

As always, subscribe, follow me on twitter to receive the latest posts!

Automate all the things! But wait a second…

Lazy dude? Listen to the audio version!


Don’t get me wrong, I love automation, I automated a lot of setups and configurations in the past, including:

  • The setup of hundreds of servers
  • software deployments
  • the installation and maintenance of my notebooks, desktops and raspberry pis for home control

I started my career without any of these tools, like ansible, puppet or stuff. We used bash and python scripts to automate routines that appear everyday…

What’s the problem with automation?

Like I told, we dont’ worked with these tools from the beginning, so we did a lot of the things by hand first, without just hitting ‘ansible do-all-the-stuff’. It took longer, sure. But after setting up the services ourselves, we know how every piece of the system works. And the more important thing, we know how to fix the system. I am not saying you shouldn’t automate, automation is great. But I met lot of people who rely on their automation system, to do all the stuff for them. They don’t know how to search for errors or fix them, because they don’t know how to setup the system without configuration management tools.   If you setup a service by hand, then you got the knowledge how to tweak the configuration and you get a better understanding and feeling for the service. You’re not looking at top or ps, ander wonder why three processes are running for dovecot. You know why the service is running, because you configured it, not ansible, not puppet.

So, what should I do?

You should automate all the things! No, nothing is wrong with me, I am not schizophrenic. But before you automate the deployment, the installation or whatever, make sure you did it once per hand. Then you got the knowledge and the feeling, how the service works and why it works like that. If you have to setup a 100 node mail or database cluster, with sharding or other crazy stuff, you’ll be glad if you know it works in the background.

What do you think? Drop me some lines in the comments!

Thanks for reading and be sure to follow me on twitter or similar! Have FUN!

TerminalCV:The Resume for Hackers and Sysadmins


As a sysadmin you don’t have the opportunities like web or graphics designers to present your resume.
Although you could do some ascii art or stuff like that.

I searched a long time for the right way, to present my skills to potential employers.
The first try resulted in this. This is ok, but that ain’t fancy or any similar…
I wanted something more ‘sysadmin’ like. So I searched the web… and found Jquery-Terminal.

A great shell-like terminal for the web. So I downloaded it and put my information into the HTML. Looked cool, really.
But would you like to change the html all the time? Probably not, so do I.

So what now?

I took a yaml-file and wrote down all the stuff I am able to do. This resulted in this:
Screenshot from 2015-09-29 18-30-56

The next step, how to bring this into the html/js file? python and jinja2.

So you take your index.html, replace all sections with jinja2 tags, for example {{ skills }}, and render it with your yaml file.

Ok it ain’t that easy 😉 But not that hard.

Don’t worry, I did that for you. You can see my example here: terminalCV

How to make use of it?

Like I said, I did all the stuff already for you.

You only need to take this 5 steps:

1. Clone the github-Repository:

2. Install the requirements:

3. Edit the about.yml with your editor:

4. Render the template:

5. Publish it wherever you want, it is plain html,css and JS, so no runtime is required.

(6. Open up a beer for doing a great job marketing yourself 😉 )
(7. Buy me a beer )

Get Your Owncloud / Caldav Calendar Into Tmux

In my previous post I promised you that I will show you how to get you owncloud calendar into tmux status bar. Since owncloud uses the caldav protocol, this post should fit for most caldav servers.

To accomplish this task I will use the python library caldav, which latest version is 0.4.0. You can easily install it via pip:

pip install caldav

If pip is not available, install it with your package manager, i.e. apt:

apt-get install python-pip python-dev

Ok, you got everything setup. Let’s start.

First you need to grab the url from your owncloud web interface. Therefore login to owncloud click on the dropdown at the top left and select calendar.

On the left side you can see your calendar(or multiple ones), which default name is personal. Next to it there is a hyperlink symbol(as you see in the screenshot).


Selection_001Below there appears a link to the caldav api of owncloud. Just copy it for later.

Now we got every information we need. Let’s have a look at the python script I have prepared:

If you got any suggestions how to make the short script better, please use the comments 😉

The script prints out your next appointment in your calendar, so we can directly call it in tmux, no sed or else is required.
So save the script, for example to ~/bin/ or /usr/local/bin/ and make it executable:

chmod +x ~/bin/

And call it from you ~/.tmux.conf:

set -g status-right '📅 #(~/bin/'

Voila! Your next appointment appears in tmux 🙂

Screenshot from 2015-07-07 08:51:40

If you got any questions, suggestions or wishes, please use the comments here on the blog. Otherwise they will be scattered at G+, Twitter and reddit.

You want to learn more about an effective workflow with tmux? Sign up for my book, of course you will get a discount with the newsletter 😉

Get your Google Calendar into TMUX

EDIT: If you need to have your caldav/owncloud calendar, have a look HERE.

The most time I work in the terminal in fullscreen mode for not getting disturbed. Therefore I like it to have my calendar(at least the next appointment) visible in my command line environment. I discovered a great tool for the command line called ‘gcalcli’. You can find it on github:

Install it via pip:

pip install gcalcli

After the installation you need to setup your account on the first connection. You can do this for example by requesting your agenda:

gcalcli agenda

A browser window will popup which is requesting your confirmation to manage your calendar:
Screenshot from 2015-06-29 21-29-10

After confirming you are able to query your calendar with the command line – GREAT! 😉

As wouldn’t that be cool enough, let’s put the calendar into tmux.

First we need to build the build the output we a few pipes and stuff:

gcalcli --nostarted --calendar "" agenda --nocolor | cut -d " " -f 4- | head -2 | tail -1 | sed "s/^ *//g" | sed "s/    / /g" | cut -c1-19

Let’s cut off the date, redundant spaces, empty lines and all the useless stuff and finally get only the next event in the calendar.
Also I only want the first 20 chars of the name, so let’s cut this ;).

Be sure to replace GOOGLE_USERNAME with your accountname(everything in front of

Now you have only the last element, so let’s get a nice calendar symbol and put it in our .tmux.conf.
Therefore your need to open your .tmux.conf modify the option ‘status-right’:
set -g status-right '📅 #(gcalcli --nostarted --calendar "" agenda --nocolor | cut -d " " -f 4- | head -2 | tail -1 | sed "s/^ *//g" | sed "s/    / /g" | cut -c1-19)'

So you are almost there, just save your file and reload your tmux config. So type your prefix(standard CTRL+B) and
:source-file ~/.tmux.conf

After a few seconds in the right bottom you should see your next event from the google calendar:
Screenshot from 2015-06-29 22-07-49
Nice! 🙂

In the next days I will write how to achieve this with your owncloud account.

Have fun and thanks for reading! 🙂


P.S.: Currently I am writing a bout about an effective workflow using tmux so don’t forget to opt in to the newsletter to get the latest updates on the work in progress.