Ansible playbooks in action
Let’s set up an Apache server for a custom website that connects with a MySQL backend—in short, a Linux, Apache, MySQL, and PHP (LAMP) stack using Ansible.
The following directory contains all resources for the exercises in this section:
$ cd ~/modern-devops/ch9/lamp-stack
We have created the following custom index.php
page that tests the connection to the MySQL database and displays whether it can connect or not:
... <?php mysqli_connect('db', 'testuser', 'Password@1') or die('Could not connect the database : Username or password incorrect'); echo 'Database Connected successfully'; ?> ...
We create several Ansible playbooks according to the logical steps we follow with CM.
It is an excellent practice to update the packages and repositories at the start of every configuration. Therefore, we need to start our playbook with this step.