Actual package name in the repo is package-2.6.12-3.el7.x86_64
.
The goal is to install a package with Ansible, to:
The repo can update packages from time to time, but I don't know when.
My thought was to install a package like this;
- name: Install package
yum:
name: package-2.6
state: present
But the task fails, because package-2.6
is not in the repo. Whereas simply package
works, but it is not future proof.
Update:
Seems wildcards *
do work, eg name: "package-2.6*"
. Ensure to quote the wildcard.
Not sure if applicable for your Yum package. But for Java Open JDK installations where both java-1.7.0 and java-1.8.0 packages are available for installation from my configured yum repos.
This will ensure the 1.7.x version is at the latest version, without ever installing 1.8.x.
- name: Install latest 1.7.x jdk
yum:
name: java-1.7.0-openjdk.x86_64
state: latest
Actual version installed from the above is:
$ rpm -q java-1.7.0-openjdk.x86_64
java-1.7.0-openjdk-1.7.0.121-2.6.8.1.el6_8.x86_64
In the case of MongoDB the package name is the same for the 2.x version and the 3.x version.
But there is one Yum repo file for the 2.x version and another for the 3.x version. https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
So to ensure you get the latest 2.x version without ever moving to 3.x add the 2.x repo file to your target hosts and use the disable
and enablerepo
parameters in your ansible task for the install/update operation.
- name: Ensure latest 2.x mongodb version is installed
yum:
name: mongodb-org
disablerepo: "*"
enablerepo: mongodb-org-2.6
state: latest
Note: using disablerepo: "*"
as mongodb packages also exist in other repos such as epel.