The wordpress role
Now that we have completed the roles that prepare our target virtual machine, 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 role init roles/wordpress
Now that we have the empty role files, we can start populating the tasks and variables in the files.
Some facts
Before installing WordPress, we must set some facts using the ansible.builtin.set_fact
module. The following task, the first in the roles/wordpress/tasks/main.yml
file, sets two variables using the information gathered when Ansible first connects to the hosts:
- name: "Set a fact for the wordpress domain" ansible.builtin.set_fact: wordpress_domain: "{{ ansible_ssh_host }}" os_family: "{{ ansible_distribution }} {{ ansible_distribution_version...