What is the difference between two "state" option values, "present" and "installed", available in Ansible's yum module?

kevmo picture kevmo · Nov 3, 2016 · Viewed 22.3k times · Source

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

Answer

Yogesh picture Yogesh · Nov 3, 2016

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.