WordPress installation tasks
Now that we have the roles that prepare our target Vagrant box completed, we can proceed with the actual WordPress installation; this will be split into a few different parts, starting with downloading wp_cli
and setting up the database.
Before we progress, we should create the role:
$ ansible-galaxy init roles/wordpress
WordPress CLI installation
WordPress CLI (WP-CLI) is a command-line tool used to administer your WordPress installation; we will be using it throughout the role, so the first thing our role should do is download it. To do this, we need to download the following variables in roles/wordpress/defaults/main.yml
:
wp_cli: download: "https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar" path: "/usr/local/bin/wp"
As you probably have gathered from the two variables, we are going to be downloading the file from wp_cli.download
and copying it to wp_cli.path
. The task in roles/wordpress/tasks/main.yml
to do this looks like the following...