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:

- name: download wp-cli
get_url:
url: "{{ wp_cli.download }}"
dest: "{{ wp_cli.path }}"

- name: update permissions of wp-cli to allow anyone to execute it
file:
path: "{{ wp_cli.path }}"
mode: "0755"

As you can see, we are downloading the .phar file, moving it, and then setting permissions so that it can be executed by anyone logged in to the server—this is important as we will be running a lot of the installation commands as the wordpress user.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.183.1