1

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?

2
  • You are positive it is not installed and just needs to be enabled? Are you checking the output of dnf module list php on the target computer before you execute your playbook. Commented May 7 at 15:23
  • I want to be able to specify which app stream to enable/use via ansible. Assuming nothing. Being able to change the config and re-run the ansible and it changes and upgrades. Commented May 14 at 13:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.