Indicating differences between files using --diff

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 change our playbooks/setup_apache.yaml playbook to match the following:

    - hosts: localhost 
      tasks: 
      - name: Ensure Apache is installed 
        yum: 
          name: httpd 
          state: present 
      - name: Ensure Apache in enabled 
        service: 
          name: httpd 
          state: running 
          enabled: True 
      - name: Ensure Apache userdirs are properly configured 
        template: 
          src: '../templates/userdir.conf' 
          dest: '/etc/httpd/conf.d/userdir.conf' 

As you can see, we added a task, which will ensure a certain state of the /etc/httpd/conf.d/userdir.conf ...

Get Learning Ansible 2 - Second Edition 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.