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
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.
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.
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 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With