Well, the official Ansible documentation for the yum module describes list as: "Various (non-idempotent) commands for usage with /usr/bin/ansible and not playbooks.". Ansible yum module is used to manage packages using the yum package manager on CentOS and RHEL based Linux distributions including, RHEL, CentOS, Fedora, etc. When using state=latest, this can be '*' which means run yum -y update. Connect and share knowledge within a single location that is structured and easy to search. apply good practice to the yum module usage by dropping the loop and installing all packages at once For the first point, the inventory and its vars would look like the following: Note: d ( []) which is an alias for default ( []) is there to make sure nothing breaks if a specific group does not have any custom modules defined. rev2023.4.21.43403. What risks are you taking when "signing in with Google"? By kwok kubernetes a Tool to Spin up Kubernetes Nodes free 1, Ansible uses Testinfra test infrastructure, Run Multiple Ansible Versions using Python 3 Virtual Environments, Ansible copy template file to remote server, Vagrant No VirtualBox Guest Additions installation found [Fixed], Jenkins build periodically with parameters, Install docker and learn containers on centos. List currently installed package version during yum update. Which was the first Sci-Fi story to predict obnoxious "robo calls"? In some cases, you will need to install multiple packages on the Target server. Your email address will not be published. These repos will not persist beyond the transaction. How to Install Kubernetes on Rocky Linux {Manual or via Ansible} I found this answer useful for using the ansible yum module instead of the shell command as recommended by the ansible warning: When a gnoll vampire assumes its hyena form, do its HP change? Parsing the results of this command is the most complete answer. Best way to check for installed yum package/rpm version Use Python code to check if a package is installed in python using yum: If the result is 0 (zero) the package is installed. If set to repoid, disable excludes defined for given repo id. Making statements based on opinion; back them up with references or personal experience. i need to check more than 100 servers for the snapd package, but I don't like the output at all. Go with techraf's solution, it has the extra. Anyway, here are some examples of enabling a repo on a single Where information on the package came from. This parameter is mutually exclusive with name. Share Improve this answer Follow e.g. Web--- - hosts: centos become: true tasks: - name: Check Hostname command: /usr/bin/hostname - name: Check for package if is installed yum: list: snapd register: Equivalent to passing the skip-broken option. Install In that case, you can use item and combine all packages in a single task. To learn more, see our tips on writing great answers. Force yum to check if cache is out of date and redownload if needed. Package groups are specified as @development-tools and environment groups are @^gnome-desktop-environment. For further actions, you may consider blocking this person and/or reporting abuse. By clicking Post Your Answer, you agree to our terms of service, privacy policy and cookie policy. If you require Python 3 support see the ansible.builtin.dnf module. If the system is registered to RHN or an RHN Satellite, repoquery allows for querying all channels assigned to the system.