Question:
I have the following task in my ansible playbook:
1 2 3 4 5 6 7 8 9 |
- 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:
They do the same thing, i.e. they are aliases to each other, see this comment in the source code of the yum module:
# removed==absent, installed==present, these are accepted as aliases
And how they are used in the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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