I have the following task in my ansible playbook:
- name: Install EPEL repo.
yum:
name: "{{ epel_repo_url }}"
state: present
register: result
until: '"failed" not in result'
retries: 5
delay: 10
Another value I can pass to state is "installed". What is the difference between the two? Some documentation available here: http://docs.ansible.com/ansible/yum_module.html
State as 'Present' and 'Installed' are used interchangeably. They both do the same thing i.e. it will ensure that a desired package in your case 'yum' is installed.
Whereas State as 'Latest' means in addition to installation, it will go ahead and update if it is not of the latest available version.
Whenever you are building your stack/app or working on production, it is always advisable to use 'Present' or 'Installed' state. This is because a software update, whether it’s your app’s deploy, or a dependency version bump, it has nothing to do with server configuration, and could really break your production.
You can read and understand more about it here.