Blog by Daniel Hauck. Sysadmin, Developer, Blogger.

In this part of the tutorial I will show you, how to use the raw module of ansible. This will be a shorter one, in which we will just install composer.


Thank to the guys at ubuntu that don’t provide a working copy of xenial for vagrant I can show you another part of ansible. In 16.04 we could install composer just via apt which at this would be quite boring, since we are real ansible pros right now.

But since we are on trusty, we thankfully need to use the raw module for now. The raw module is just like running a command in bash. Really it’s easy as that. So let’s create a new role. If you want you could also simply put it into the php role, but don’t yell at me, if you can’t find it later 😉

First get the install script for programmatically installation from

and save it to provisioning/composer/files/

Next we need to actually transfer the script to our vagrant machine and run it. So same as every day, let’s create our main.yml and use the copy module to transfer the file to the remote machine:

Now let’s run it! or better let’s tell ansible to run it with the raw module:

This results in creating a file called composer.phar in the home dir of the vagrant user. Let’s move it to a more usual space for example /usr/local/bin/, of course with the raw command (and get rid of the file extension:

That’s it! Our composer role is ready. Almost.
Don’t forget to add the new role to playbook.yml:

And we can now run our provisioning again:

Bam, your output should look something like this:

And we are done

At least for today. Tomorrow I will show you how to install nginx and add virtual hosts to it.

Stay tuned, see you guys tomorrow. Thanks for reading and don’t forget to subscribe either to the newsletter or any social platforms. Thank you!

There are no comments.

Leave a Reply