Running the playbook

There are no changes to our site.yml file, meaning that we just need to run the following command to start the playbook run:

$ ansible-playbook -i production site.yml

This will run through the playbook, giving the following output; please note that I have trimmed a few parts of the playbook output:

PLAY [wordpress]

TASK [Gathering Facts]
ok: [centos]
ok: [ubuntu]

TASK [roles/stack-install : include the operating system specific variables]
ok: [centos]
ok: [ubuntu]

TASK [roles/stack-install : install the repo packages]
skipping: [ubuntu] => (item=[])
changed: [centos] => (item=[u'epel-release', u'https://centos7.iuscommunity.org/ius-release.rpm'])

TASK [roles/stack-install : add the NGINX mainline repo]
skipping: [ubuntu]
changed: [centos]

TASK [roles/stack-install : update all of the installed packages]
skipping: [ubuntu]
changed: [centos]

TASK [roles/stack-install : remove the packages so that they can be replaced]
skipping: [ubuntu]
changed: [centos] => (item=[u'mariadb-libs.x86_64'])

TASK [roles/stack-install : install the stack packages]
skipping: [ubuntu] => (item=[])
changed: [centos] => (item=[u'postfix', u'MySQL-python', u'policycoreutils-python', u'nginx', u'mariadb101u', u'mariadb101u-server', u'mariadb101u-config', u'mariadb101u-common', u'mariadb101u-libs', u'php72u', u'php72u-bcmath', u'php72u-cli', u'php72u-common', u'php72u-dba', u'php72u-fpm', u'php72u-fpm-nginx', u'php72u-gd', u'php72u-intl', u'php72u-json', u'php72u-mbstring', u'php72u-mysqlnd', u'php72u-process', u'php72u-snmp', u'php72u-soap', u'php72u-xml', u'php72u-xmlrpc', u'vim-enhanced', u'git', u'unzip'])

TASK [roles/stack-install : update cache and install the system packages]
skipping: [centos] => (item=[])
changed: [ubuntu] => (item=[u'software-properties-common', u'python3-mysqldb', u'acl'])

TASK [roles/stack-install : add the apt keys from a key server]
skipping: [centos]
changed: [ubuntu] => (item={u'key_server': u'keyserver.ubuntu.com', u'key': u'0xF1656F24C74CD1D8'})

TASK [roles/stack-install : add the apt keys from a URL]
skipping: [centos]
changed: [ubuntu] => (item=http://nginx.org/keys/nginx_signing.key)

TASK [roles/stack-install : install the repo packages]
skipping: [centos] => (item=epel-release)
skipping: [centos] => (item=https://centos7.iuscommunity.org/ius-release.rpm)
changed: [ubuntu] => (item=deb [arch=amd64,i386] http://mirror.sax.uk.as61049.net/mariadb/repo/10.1/ubuntu zesty main)
changed: [ubuntu] => (item=deb http://nginx.org/packages/mainline/ubuntu/ zesty nginx)
changed: [ubuntu] => (item=deb-src http://nginx.org/packages/mainline/ubuntu/ zesty nginx)

TASK [roles/stack-install : install the stack packages]
skipping: [centos] => (item=[])
changed: [ubuntu] => (item=[u'nginx', u'mariadb-server', u'php7.0', u'php7.0-cli', u'php7.0-fpm', u'php7.0-gd', u'php7.0-json', u'php7.0-mbstring', u'php7.0-mysqlnd', u'php7.0-soap', u'php7.0-xml', u'php7.0-xmlrpc', u'vim', u'git', u'unzip'])

TASK [roles/stack-config : include the operating system specific variables]
ok: [centos]
ok: [ubuntu]

TASK [roles/stack-config : add the wordpress group]
ok: [centos]

TASK [roles/stack-config : create the global directory in /etc/nginx/]
changed: [ubuntu]
ok: [centos]

TASK [roles/stack-config : add the wordpress user]
changed: [centos]
changed: [ubuntu]

TASK [roles/stack-config : copy the nginx.conf to /etc/nginx/]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : create the global directory in /etc/nginx/]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : copy the restrictions.conf to /etc/nginx/global/]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : copy the wordpress_shared.conf to /etc/nginx/global/]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : copy the default.conf to /etc/nginx/conf.d/]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : copy the www.conf to /etc/php-fpm.d/]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : configure php.ini]
changed: [ubuntu] => (item={u'regexp': u'^;date.timezone =', u'replace': u'date.timezone = Europe/London'})
changed: [centos] => (item={u'regexp': u'^;date.timezone =', u'replace': u'date.timezone = Europe/London'})
ok: [ubuntu] => (item={u'regexp': u'^expose_php = On', u'replace': u'expose_php = Off'})
changed: [centos] => (item={u'regexp': u'^expose_php = On', u'replace': u'expose_php = Off'})
changed: [ubuntu] => (item={u'regexp': u'^upload_max_filesize = 2M', u'replace': u'upload_max_filesize = 20M'})
changed: [centos] => (item={u'regexp': u'^upload_max_filesize = 2M', u'replace': u'upload_max_filesize = 20M'})

TASK [roles/stack-config : start php-fpm]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : start nginx]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : configure the mariadb bind address]
skipping: [ubuntu]
changed: [centos]

TASK [roles/stack-config : start mariadb]
ok: [ubuntu]
changed: [centos]

TASK [roles/stack-config : change mysql root password]
changed: [centos] => (item=127.0.0.1)
changed: [ubuntu] => (item=127.0.0.1)
changed: [centos] => (item=::1)
changed: [ubuntu] => (item=::1)
changed: [ubuntu] => (item=192)
changed: [centos] => (item=192.168.50.6.nip.io)
changed: [ubuntu] => (item=localhost)
changed: [centos] => (item=localhost)

TASK [roles/stack-config : set up .my.cnf file]
changed: [ubuntu]
changed: [centos]

TASK [roles/stack-config : delete anonymous MySQL user]
ok: [ubuntu] => (item=127.0.0.1)
ok: [centos] => (item=127.0.0.1)
ok: [ubuntu] => (item=::1)
ok: [centos] => (item=::1)
ok: [ubuntu] => (item=192)
changed: [centos] => (item=192.168.50.6.nip.io)
ok: [ubuntu] => (item=localhost)
changed: [centos] => (item=localhost)

TASK [roles/stack-config : remove the MySQL test database]
ok: [ubuntu]
changed: [centos]

TASK [roles/stack-config : set the selinux allowing httpd_t to be permissive is required]
skipping: [ubuntu]
changed: [centos]

TASK [roles/wordpress : set a fact for the wordpress domain]
ok: [centos]
ok: [ubuntu]

TASK [roles/wordpress : download wp-cli]
changed: [ubuntu]
changed: [centos]

TASK [roles/wordpress : update permissions of wp-cli to allow anyone to execute it]
changed: [ubuntu]
changed: [centos]

TASK [roles/wordpress : create the wordpress database]
changed: [ubuntu]
changed: [centos]

TASK [roles/wordpress : create the user for the wordpress database]
changed: [ubuntu] => (item=127.0.0.1)
changed: [centos] => (item=127.0.0.1)
ok: [ubuntu] => (item=::1)
ok: [centos] => (item=::1)
ok: [ubuntu] => (item=192)
ok: [centos] => (item=192.168.50.6.nip.io)
ok: [ubuntu] => (item=localhost)
ok: [centos] => (item=localhost)

TASK [roles/wordpress : are the wordpress files already there?]
ok: [ubuntu]
ok: [centos]

TASK [roles/wordpress : download wordpresss]
changed: [ubuntu]
changed: [centos]

TASK [roles/wordpress : set the correct permissions on the homedir]
ok: [ubuntu]
changed: [centos]

TASK [roles/wordpress : is wordpress already configured?]
ok: [centos]
ok: [ubuntu]

TASK [roles/wordpress : configure wordpress]
changed: [ubuntu]
changed: [centos]

TASK [roles/wordpress : do we need to install wordpress?]
fatal: [ubuntu]: FAILED! =>
...ignoring
fatal: [centos]: FAILED! =>
...ignoring

TASK [roles/wordpress : install wordpress if needed]
changed: [ubuntu]
changed: [centos]

TASK [roles/wordpress : do we need to install the plugins?]
failed: [ubuntu] (item=jetpack) =>
failed: [ubuntu] (item=wp-super-cache) =>
failed: [ubuntu] (item=wordpress-seo) =>
failed: [centos] (item=jetpack) =>
failed: [ubuntu] (item=wordfence) =>
failed: [centos] (item=wp-super-cache) =>
failed: [ubuntu] (item=nginx-helper) =>
failed: [centos] (item=wordpress-seo) =>
failed: [centos] (item=wordfence) =>
failed: [centos] (item=nginx-helper) =>

TASK [roles/wordpress : set a fact if we don't need to install the plugins]
skipping: [centos]
skipping: [ubuntu]

TASK [roles/wordpress : set a fact if we need to install the plugins]
ok: [centos]
ok: [ubuntu]

TASK [roles/wordpress : install the plugins if we need to or ignore if not]
changed: [centos] => (item=jetpack)
changed: [ubuntu] => (item=jetpack)
changed: [ubuntu] => (item=wp-super-cache)
changed: [centos] => (item=wp-super-cache)
changed: [ubuntu] => (item=wordpress-seo)
changed: [centos] => (item=wordpress-seo)
changed: [ubuntu] => (item=wordfence)
changed: [centos] => (item=wordfence)
changed: [ubuntu] => (item=nginx-helper)
changed: [centos] => (item=nginx-helper)

TASK [roles/wordpress : do we need to install the theme?]
fatal: [centos]: FAILED! =>
fatal: [ubuntu]: FAILED! =>

TASK [roles/wordpress : set a fact if we don't need to install the theme]
skipping: [centos]
skipping: [ubuntu]

TASK [roles/wordpress : set a fact if we need to install the theme]
ok: [centos]
ok: [ubuntu]

TASK [roles/wordpress : install the theme if we need to or ignore if not]
changed: [centos]
changed: [ubuntu]

RUNNING HANDLER [roles/stack-config : restart nginx]
changed: [ubuntu]
changed: [centos]

RUNNING HANDLER [roles/stack-config : restart php-fpm]
changed: [ubuntu]
changed: [centos]

PLAY RECAP
centos : ok=47 changed=37 unreachable=0 failed=0
ubuntu : ok=45 changed=33 unreachable=0 failed=0

Once the playbook has finished, you should be able to access http://192.168.50.6.nip.io/ in your browser, and you should see WordPress showing that it is installed on a Red Hat-based operating system:

Going to http://192.168.50.7.nip.io/ will show the same theme, but it should state that it is running in a Debian-based operating system, as in this screenshot:

You can try rerunning your playbook to see what results are returned, and also you can remove the Vagrant boxes by running:

$ vagrant destroy

You will be asked if you want to remove each machine one at a time; just answer yes to each of the two prompts.