diff --git a/changelogs/fragments/61234-yum-dnf-version-comp-doc.yml b/changelogs/fragments/61234-yum-dnf-version-comp-doc.yml new file mode 100644 index 00000000000..e50f66d36a6 --- /dev/null +++ b/changelogs/fragments/61234-yum-dnf-version-comp-doc.yml @@ -0,0 +1,2 @@ +minor_changes: + - Add yum/dnf version comparison documentation for package install diff --git a/lib/ansible/modules/dnf.py b/lib/ansible/modules/dnf.py index bfdd5544b02..38f80094811 100644 --- a/lib/ansible/modules/dnf.py +++ b/lib/ansible/modules/dnf.py @@ -25,6 +25,7 @@ options: When using state=latest, this can be '*' which means run: dnf -y update. You can also pass a url or a local path to a rpm file. To operate on several packages this can accept a comma separated string of packages or a list of packages." + - Comparison operators for package version are valid here C(>), C(<), C(>=), C(<=). Example - C(name>=1.0) required: true aliases: - pkg @@ -250,6 +251,11 @@ EXAMPLES = ''' name: httpd state: latest +- name: Install Apache >= 2.4 + dnf: + name: httpd>=2.4 + state: present + - name: Install the latest version of Apache and MariaDB dnf: name: diff --git a/lib/ansible/modules/yum.py b/lib/ansible/modules/yum.py index 9b636bdfbd3..3a74eced0fb 100644 --- a/lib/ansible/modules/yum.py +++ b/lib/ansible/modules/yum.py @@ -33,6 +33,7 @@ options: name: description: - A package name or package specifier with version, like C(name-1.0). + - Comparison operators for package version are valid here C(>), C(<), C(>=), C(<=). Example - C(name>=1.0) - If a previous version is specified, the task also needs to turn C(allow_downgrade) on. See the C(allow_downgrade) documentation for caveats with downgrading packages. - When using state=latest, this can be C('*') which means run C(yum -y update). @@ -277,6 +278,11 @@ EXAMPLES = ''' name: httpd state: latest +- name: Install Apache >= 2.4 + yum: + name: httpd>=2.4 + state: present + - name: Install a list of packages (suitable replacement for 2.11 loop deprecation warning) yum: name: