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 ...

Get Learn Ansible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.