Reputation: 4232
In the docs of Ansible, http://docs.ansible.com/ansible/yum_module.html#options
There is a comment about "state" parameter:
Whether to install (present or installed, latest), or remove (absent or removed) a package.
My question is:
Are there any differences between the 3 choices(present, installed, latest)?Which one should I use when I run these commands below?
yum clean all && yum makecache
yum upgrade
Upvotes: 1
Views: 6492
Reputation: 4973
Yum clean
is not available in the yum
module, so best to use the command
module:
- name: Perform a yum clean
command: /usr/bin/yum clean all
For makecache
you can use the yum
module:
- name: Ensure the yum package index is up to Date
yum:
update_cache: yes
name: '*'
state: latest
And also use the yum
module for upgrade
:
- name: upgrade all packages
yum:
name: '*'
state: latest
Upvotes: 5
Reputation: 6588
There is no ways to clean on the yum module. You just have to use command module:
- name: Clean all packages
command: yum clean all && yum makecache
Upvotes: 1
Reputation: 68299
present
(installed
is the same, but deprecated) ensures that package is in the system. If it is there, module exits unchanged; If it is not, package is installed and module exits with changed state.
latest
ensures that the latest available version of package is in the system. If the latest version already installed, module exits unchanged; If it is not installed or version is not up-to-date, module installs the latest versions and exits with changed state.
Example from the docs:
- name: upgrade all packages
yum:
name: '*'
state: latest
Upvotes: 2