Automatically installing all Ansible role dependencies

I think it was a couple of months ago now that I first started to fiddle around with Ansible. Being used to work with Puppet as a system provision tool before, Ansible seemed to make this task I disliked so bad before very easy. Almost fun I guess.

One thing that I found missing though, was a way to automatically install all the role dependencies. This still seems to be a task you have to do manually. Or anyway, I can’t find a way how to do it with the current Ansible version. So, being a programmer and all, I wrote a script for it.

The script itself is very simple:

  1. Loops through every role installed in roles/
  2. For every role, it fetches dependencies from meta/main.yml
  3. Installs the dependencies via Ansible galaxy

Personally I haven’t found a use case for other features, but if you do, please let me know.

The script source is available here: GitHub link
Available for download here: Direct download

Happy coding!

Charles is my superhero!

As a true geek I am a big fan of several superheroes. Actually, Iron Man is by far my favourite one. Or actually, the coolest part about Iron Man is J.A.R.V.I.S. if you ask me. The Just A Rather Very Intelligent System, is a clever system that assists Tony Stark in virtually everything that he considers “everyday tasks”.

Unfortonately I do not embody a superhero, but I do have several tools that assist me with my everyday tasks, and one of these tools is Charles Proxy.
Like my IDE helps me with being productive in writing, testing and troubleshooting code, Charles Web Debugging Proxy helps me with most of the things that are related to HTTP. And as a web developer, you know, that’s a lot. Here are some of the most significant contributions of Charles in my everyday work.

Communication insight

Specifically when developing APIs, a lot of communication is happening “under water”. A website does a request to an API, or a mobile device calls some webservices, and you want to know what’s going on. As with most proxies, Charles can show the HTTP-client requests. What’s connecting when, to where, and with what headers, cookies, request/response bodies etc.

Request tampering

Screen Shot 2013-07-25 at 20.34.59By setting a breakpoint on a specific request, you can modify the entire HTTP request the client is sending to the server. Change headers, cookies, request bodies, query parameters. In short, everything that you need to troubleshoot most common HTTP-related issues. Activate this in the context menu of a specific request -> Breakpoints, and the next time your client requests this URL, charles will break on the request.

Give colleagues and devices access to your dev environment

Another very convenient feature is that if you set your proxy server as a system-wide proxy on let’s say, your mobile device or colleagues’ machine, that they can see everything web-accessible on the machine you’re running Charles on.
So in practice, it means that you can check out your application that’s running on let’s say, a host-only connected virtual machine. This is something that we use a lot here in the office. Pretty neat, huh?

But there’s more…

Actually, the list above is just the tip of the iceberg of Charles’ features. There are a lot more features in the application, like: Bandwidth throttling, Request filtering, Recording/Replaying and saving sessions, DNS spoofing, SSL proxying, and there’s still more.

So, why a blog about Charles’ features while I could also visit it’s website?

Well, if you’ve read this far, I’ve got your attention. And that’s exactly what I was after. My goal with this post is to show that there’s a tool that can help you with things that can be very cumbersome without a proxy. And more! Charles is just great, and every web developer should at least know about it’s existence.

Of course, Charles is not the only Proxy program out there, and probably there are tools that have more or less the same features. If you know such a tool, could you let me know in the comments?
Oh, and Charles runs on virtually every desktop platform!

PHP CLI remote debugging with PhpStorm & Zend Debugger

This post aims to give an overview of how to get remote cli debugging working with PhpStorm and Zend Debugger. You can find more detailed information under the links in this article.

Some time ago i wanted to debug a PHPUnit test in PhpStorm, debugging PHP scripts using the cli sapi turned out to require some extra effort.

The situation is that my project files reside in a virtualbox, and open the project files -via a mounted directory- in PhpStorm. This means that, for normal web debugging, you have to specify some server settings, including the path mapping.

Since you work on the server directly, you have to set up a remote debugging connection to your IDE. In his blog post, Kevin Schroeder explains how to do this.
You can do this by running the following command, as copied from Kevin’s post:

Don’t forget to change the IP-address and port to the address that you’re IDE is running on.

Now there is one more thing you have to do to make PhpStorm understand where the files are, otherwise you still wouldn’t hit those breakpoints.
According to this article from the JetBrains team, this can be done by setting the PHP_IDE_CONFIG environment variable to “serverName=name-of-server” where name-of-server is the name as configured in Project Settings -> PHP -> Servers.

And oh, make sure your “Listen to Debug connections” button is green!

As i work with different projects on the same virtualbox, i have created this small script that you can put in your .bashrc

You can enable debugging by running:

$ bugon server-name

And disable by running:

$ bugoff

Happy debugging!

Easy SASS compilation in WebStorm / PhpStorm

If you are a regular reader, you might have noticed i have started using SASS a while go. If you are not, and don’t know what sass is, you can read my previous post on sass here.

Recently Webstorm/PhpStorm introduced the support for sass syntax highlighting, which is really awesome, but the compilation of SASS files is not integrated in the IDE.
There is however a way to set up Webstorm/PhpStorm to use external tools, which is perfect to make sass compilation from within the IDE possible.

Just follow the steps below, and you can enjoy the comfort of SASS compilation from within your favourite IDE.

Open the Settings panel: File > Settings

Then go to “External Tools” and click “Add…”

The following screen shows up, fill in the values you see (but point the “program” field to your sass installation path)

Now, right click on your SASS (or scss) file, and the sass tool will be right there, as you can see in the screen below.

Some additional useful tips:

  • Alternatively, if you prefer the one time compilation, or other sass parameters, just change the “parameters” field, or create some duplicates of this external tool setup.
  • If you work with “deploy to FTP” on save, make sure to enable the “Upload external changes” option.

Sass – Stylesheet tool

Sass logoNow this tool you are going to read about is nothing new. In fact, it’s been around since 2007 according to Wikipedia, but i have to share it with you because it will make your life easier!

“Syntactically Awesome Stylesheets” is what Sass stands for and is a tool to make several things related to writing and deploying stylesheets easier. It is a command line tool written in Ruby, and is available as a ruby gem.

For writing stylesheets Sass has a couple of (language)features. For instance it supports variables, calculations, includes and this thing they call ‘mixins’; some sort of templates or functions.

Sass or actually, since version 3 they call them .scss, files need to be converted to normal a CSS file so you can use it like any other CSS file in your browser. This conversion is being done by the command line tool.

One of the most interesting features of this tool is that you can tell sass in what format it needs to output the css format. It can render normal (extended) css, but also in a compact or compressed way.
This is useful when you have deployment scripts for different environments.
Also, while developing, don’t worry about having to run the command every time while: with the –watch switch sass will automatically watch your scss file for changes and render a new css file each time it’s saved.

I really like tools that are easy to use, require no configuration and require no alteration of my workflow process and Sass is definitely one of them!
If you want to learn more about Sass or want to start using it right away, check out their website!

Using a PHP IDE: The start of a journey

So this week i’ve started the epic journey of setting up an environment to make full use of an integrated development environment for PHP.

Now using version control, develop locally, debugging, auto code-completion etc. is something i’ve heard a lot of people talk about lately.
Not because it’s a hot-topic, but because it’s mandatory for every (PHP) developer that wants to make full use of his or hers creative mind. Yes that’s right, what i considered first to be “Overhead” like version control seems to be mandatory for making your life as a developer easier.

As my day to day job requires me to work with several developers directly on a FTP server, i was never able to use a PHP IDE to it’s full extent. Things like debugging, auto code completion, version merging do not seem to be possible with *any* PHP IDE when you work directly onto a FTP server. So this has to change. And besides, this leads to a lot of problems which i probably don’t even have to explain.

Now that i am becoming more interested in Open Source development i have to do some research on how to set this all up.
Which is exactly what i am going to do this weekend.

There are a couple of problems i ran into before even starting to set things up. I still have to think of a solution to these:

  • Database version control
  • Automatic deployment
  • Merging feature branches to the testing/staging/live branches

Probably how to handle database version control concerns me the most, have to read up on that a bit more.

PS: Any idea’s, tips or tricks are welcome, as i am fairly new to all of this!