Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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

like image 502
kevmo Avatar asked Nov 03 '16 20:11

kevmo


People also ask

How do I know if Ansible package is installed?

How can I check if a software package is installed on a Linux system using Ansible?. You can use Ansible automation tool to query installation status of a package on Linux a system. From the results a condition can then be used, e.g skip a task if package is installed, or install if check status is failed.

What is yum module in Ansible?

Ansible's yum module is used to manage packages with the yum package manager, which is the default on Red Hat based Linux distributions such as Red Hat Enterprise Linux and CentOS. Most systems require root/superuser permissions to manage packages, which means that become: true is required.

What are the modules in Ansible?

Modules (also referred to as “task plugins” or “library plugins”) are discrete units of code that can be used from the command line or in a playbook task. Ansible executes each module, usually on the remote managed node, and collects return values. In Ansible 2.10 and later, most modules are hosted in collections.

How can I set the path or any other environment variables for a task or entire playbook?

How can I set the PATH or any other environment variable for a task or entire play?  Setting environment variables can be done with the environment keyword. It can be used at the task or other levels in the play.


1 Answers

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.

like image 176
Yogesh D Avatar answered Sep 21 '22 07:09

Yogesh D