In the check mode, you can use the --diff option to show the changes that would be applied to a file. To be able to see the --diff option in use, we need to create a playbooks/setup_and_config_apache.yaml playbook to match the following:
- hosts: all
tasks:
- name: Install Apache
yum:
name: httpd
state: present
become: True
- name: Enable Apache
service:
name: httpd
state: started
enabled: True
become: True
- name: Ensure Apache userdirs are properly configured
template:
src: ../templates/userdir.conf
dest: /etc/httpd/conf.d/userdir.conf
become: True
As you can see, we added a task that will ensure a certain state of the /etc/httpd/conf.d/userdir.conf file.
We also need to create a template file placed in templates/userdir.conf with...