WordPress system user

The defaults for the WordPress system user, which should be placed in roles/stack-config/defaults/main.yml, are as follows:

wordpress_system:
user: "wordpress"
group: "php-fpm"
comment: "wordpress system user"
home: "/var/www/wordpress"
state: "present"

We are referring to this as the system user as we will be creating a user in WordPress later in the chapter. This user's details will also be defined in Ansible, so we do not want to get the two different users confused.

The task that uses these variables, found in roles/stack-config/tasks/main.yml, should look like this:

- name: add the wordpress user
user:
name: "{{ wordpress_system.user }}"
group: "{{ wordpress_system.group }}"
comment: "{{ wordpress_system.comment }}"
home: "{{ wordpress_system.home }}"
state: "{{ wordpress_system.state }}"

As you can see, we are not adding a key to the user this time as we don't want to be logging in to the user account to start manipulating files and other actions. This should all be done within WordPress itself or by using Ansible.