Creating the WordPress database

The next part of the role creates the database our WordPress installation will use; as per the other tasks in this chapter, it uses a nested variable, which can be found in roles/wordpress/defaults/main.yml:

wp_database:
name: "wordpress"
username: "wordpress"
password: "W04DPr3S5"

The tasks in roles/wordpress/tasks/main.yml to create the database and user look like the following:

- name: create the wordpress database
mysql_db:
db: "{{ wp_database.name }}"
state: "present"

- name: create the user for the wordpress database
mysql_user:
name: "{{ wp_database.username }}"
password: "{{ wp_database.password }}"
priv: "{{ wp_database.name }}.*:ALL"
state: "present"
with_items: "{{ mariadb.hosts }}"

Notice how we are using the mariadb.hosts variable from the previous role. Now that we have the database created, we can make a start on downloading and installing WordPress.

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

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