We manage our Oracle Linux 9 servers using ansible. Oracle Linux use Appstream repos in order to provide the option to install newer versions of some packages. For example, the base version of PHP is 8.0 and Node JS is 16, but you can install PHP 8.1 or 8.2 and Node JS up to version 22 from the Appstream
For example, to install PHP 8.2 the docs say to run
dnf install @php:8.2
So I expected via ansible to be able to use
- name: Install PHP 8.2 (this is what I think should work)
dnf:
name:
- '@php:8.2'
state: latest
But this doesn't work. It doesn't throw an error, it just doesn't do anything. Shows as "OK" in ansible output but nothing installed either.
I can see two possible workarounds. One is to just use a raw command from ansible for everything
- name: Install PHP 8.2 using raw command
command: dnf --best -y install @php:8.2
The other is to use a command to switch the stream then an ordinary dnf to do the install
- name: Activate PHP 8.2 stream using raw command
command: dnf -y module switch-to php:8.2
- name: Install PHP
dnf:
name:
- php
state: latest
However, both of these use a command in some fashion and so lose track of what changed. Is there a "proper" way to do this using just ansible modules without using a command?
dnf module list phpon the target computer before you execute your playbook.