What is the difference between the two “state”, “current” and “set” values ​​available in the Ansible yum module?

I have the following task in my unoccupied play:

- name: Install EPEL repo. yum: name: "{{ epel_repo_url }}" state: present register: result until: '"failed" not in result' retries: 5 delay: 10 

Another value that I can pass to the state is set. What is the difference between the two? Some documents are available here: http://docs.ansible.com/ansible/yum_module.html

+7
centos yum ansible epel
source share
2 answers

They do the same thing, they are aliases to each other, see this comment in the yum module source code:

# removed==absent, installed==present, these are accepted as aliases

And how are they used in the code:

 if state in ['installed', 'present']: if disable_gpg_check: yum_basecmd.append('--nogpgcheck') res = install(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos) elif state in ['removed', 'absent']: res = remove(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos) elif state == 'latest': if disable_gpg_check: yum_basecmd.append('--nogpgcheck') res = latest(module, pkgs, repoq, yum_basecmd, conf_file, en_repos, dis_repos) else: # should be caught by AnsibleModule argument_spec module.fail_json(msg="we should never get here unless this all" " failed", changed=False, results='', errors='unexpected state') return res 

https://github.com/ansible/ansible-modules-core/blob/devel/packaging/os/yum.py

+4
source share

A state of “ Present ” and “ Installed ” are used interchangeably. They both do the same thing, that is, they guarantee that the correct package is installed in your "yum" case.

While the “ Recent ” status means in addition to the installation, it will continue and be updated if it does not belong to the latest available version.

Whenever you create your stack / application or work on production, it is always recommended to use Presence or Installed . This is because a software update, regardless of whether your applications or dependency bytes are being deployed, has nothing to do with the server configuration and can really disrupt your production.

You can read and understand about it here .

+4
source share

All Articles