Visiting Phansible: Flint Web Ansible-based Vagrant Box Generator

Overnight I ran into this nice interesting project https://github.com/Phansible/phansible.
Don’t worry http://puphpet.com is not dead, at least not yet. Phansible still needs to support many more options before going mainstream. Users on puphpet side are many more so far and puphpet is being tested by many companies that have validated the generation. However Phansible is a very good promise built around ansible. And promises to get closer or even close the puphpet club in the future.

Phansible uses ansible recipe generation using twig and flint to generate from a webserver and some parameters or selections input into it a nice little zip file with your recipies and vagrant file. It generates playbooks, vagrantfiles, and varfiles.

You can just:

git clone git@github.com:Phansible/phansible.git
cd phansible
composer install
php vendor/bin/phpunit -c tests/phpunit.xml
php -S localhost:8080 -t web/

Though we are not very proud of the unit tests they exist and run fast. Though thoughts are being put together to improve that lacking side. Testing an app based on flint or pimple or such that inject the app into itself or such things is a bit weird as it is not inherently decoupled.

The project source code also contains a little gift which is the ansible folder. Yes the files used to deploy the same site :). This and how things get generated also for new projects will teach you a lot about ansible even if you don’t know anything about it.

When you want to generate things just go to the website or your local box deployed:

Screenshot 2014-09-10 05.40.23

vagrant up
 
// ...
 
 
PLAY [all] ********************************************************************
 
GATHERING FACTS ***************************************************************
ok: [192.168.33.99]
 
TASK: [init | Update apt] *****************************************************
ok: [192.168.33.99]
 
TASK: [init | Install System Packages] ****************************************
changed: [192.168.33.99] => (item=curl,wget,python-software-properties)
 
TASK: [init | Add ppa Repository] *********************************************
changed: [192.168.33.99]
 
TASK: [init | Update apt] *****************************************************
ok: [192.168.33.99]
 
TASK: [init | Install Extra Packages] *****************************************
changed: [192.168.33.99] => (item=vim,imagemagick)
 
TASK: [nginx | Install Nginx] *************************************************
changed: [192.168.33.99]
 
TASK: [nginx | Change default nginx site] *************************************
changed: [192.168.33.99]
 
TASK: [php5-fpm | Install php5-fpm and php5-cli] ******************************
changed: [192.168.33.99] => (item=php5-fpm,php5-cli)
 
TASK: [php5-fpm | Set permissions on socket - owner] **************************
changed: [192.168.33.99]
 
TASK: [php5-fpm | Set permissions on socket - group] **************************
changed: [192.168.33.99]
 
TASK: [php5-fpm | Set permissions on socket - mode] ***************************
changed: [192.168.33.99]
 
TASK: [phpcommon | Install PHP Packages] **************************************
failed: [192.168.33.99] => (item=php5-cli,php5-curl,php5-imagick,php-pear,php5-cgi,php5-common,php5-dbg,php5-enchant,php5-fpm,php5-gd,php5-geoip,php5-gmp,php5-imap,php5-interbase,php5-intl,php5-ldap,php5-mapscript,php5-mbstring,php5-mcrypt,php5-memcache,php5-memcached,php5-odbc,php5-pspell,php5-readline,php5-recode,php5-snmp,php5-sqlite,php5-svn,php5-sybase,php5-tidy,php5-xcache,php5-xdebug,php5-xmlrpc,php5-xsl) => {"failed": true, "item": "php5-cli,php5-curl,php5-imagick,php-pear,php5-cgi,php5-common,php5-dbg,php5-enchant,php5-fpm,php5-gd,php5-geoip,php5-gmp,php5-imap,php5-interbase,php5-intl,php5-ldap,php5-mapscript,php5-mbstring,php5-mcrypt,php5-memcache,php5-memcached,php5-odbc,php5-pspell,php5-readline,php5-recode,php5-snmp,php5-sqlite,php5-svn,php5-sybase,php5-tidy,php5-xcache,php5-xdebug,php5-xmlrpc,php5-xsl"}
msg: No package matching 'php5-mbstring' is available
 
FATAL: all hosts have already failed -- aborting
 
PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/cordoval/playbook.retry
 
192.168.33.99              : ok=12   changed=9    unreachable=0    failed=1
 
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

I got an error, but it is just probably because some updates were missing on the extensions.

There are some PRs about including frameworks however the best bet if you want to generate your own boxes and custom stuff is to clone and deploy privately a version of this. This way you can have your own recipies included. Though i strongly encourage you to share them with the rest of us!

Remember this is just the first stage of generation, you now can fix the generated files by hand, don’t forget to git init and ignore the .vagrant and other generated folders. After the fix just rerun the vagrant up or vagrant reload and then voila!

Personally I don’t use vagrant when I am a solo consultant but only when I work on a team environment. I am trying to improve a box generated by puphpet via phansible generated files now. Notice they will include Erika Heidi and other’s improvements so it is good to follow good practices from people that work with vagrant a lot more!

There are good practices also for writing ansible files here http://www.reinteractive.net/posts/167-ansible-real-life-good-practices

Encouragements and for now this is it, I will try to share more as I come more acquainted with phansible generation and testing boxes. Don’t forget to retweet please!

Leave a Reply

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