O'Reilly logo

Learning Ansible 2 - Second Edition by Fabio Alessandro Locati

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required