Installing PHP7 on Ubuntu with Ansible

In a bid to keep updated with the latest and greatest in PHP-land, I have been slowly updating my Ansible set-up to accommodate PHP7.

Fortunately, pretty much all of the hard work has been taken care of by Jeff Geerling, with his fantastic geerlingguy/php role. A mighty big thank you is in order.

But I’m writing this as I struggled with a particular issue getting my newly updated playbook to work properly.

The issue I had was that I had the following:

And whilst everything looked good, whenever I ran the playbook:

The cheeky little blighter would not run the task to add the repository before it would try and run the  roles content. Needless to say, red error text appeared in quantity.

Annoyingly, I could comment out the roles section, and the task would run – but as soon as I put the role definition back in, that would always run first.

I must admit, this was a new one on me.

However, the solution is incredibly simple:

Please note: this config is still very much a work in progress for me. I found this particular set of config from this ticket on Jeff Geerling’s Ansible Role PHP repo.

Yes, there are  pre_tasks and  post_tasks available – new ones on me, but right there in the docs. You may need to ctrl+f to find the exact examples, as I can’t directly link to the specific section unfortunately.

Very useful anyway, and with that, my task started behaving exactly as I wanted.

Ansible is absolutely awesome. If you haven’t already done so, be sure to check out my Ansible tutorial course here at Code Review Videos. It’s completely free.

 

 

Shares

Published by

Code Review

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

Leave a Reply

Your email address will not be published. Required fields are marked *