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

Working with iterates in Ansible

You may have noticed that up to now we have never used cycles, so every time we had to do multiple, similar operations, we wrote the code multiple times. An example of this is the webserver.yaml code.

In fact, this was the content of the webserver.yaml file:

--- - hosts: webserver remote_user: ansible tasks: - name: Ensure the HTTPd package is installed yum: name: httpd state: present become: True - name: Ensure the HTTPd service is enabled and running service: name: httpd state: started enabled: True become: True - name: Ensure HTTP can pass the firewall firewalld: service: http state: enabled permanent: True immediate: True become: True - name: Ensure HTTPS can pass the firewall firewalld: service: https state: ...

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