I am running a GHA workflow that uses an Ubuntu 22.04 runner to run an Ansible playbook on an Amazon Linux 2 EC2 instance on every step that uses the ansible.builtin.yum module, for example:
- name: 'Install selinux dependency packages'
ansible.builtin.yum:
name: '{{ yum_selinux_packages }}'
state: present
disable_gpg_check: true
when: 'os != "amzn2023"'
throws the error:
fatal: [default]: FAILED! => {"ansible_facts": {"pkg_mgr": "unknown"}, "changed": false, "msg": ["Could not detect which major revision of dnf is in use, which is required to determine module backend.", "You should manually specify use_backend to tell the module whether to use the dnf4 or dnf5 backend})"]}
This happens since I updated the runners (the playbook is the same as in the past) with the latest versions of some tools and also with:
&& rm -rf /home/runner/.local/lib/python3.10/site-packages/ansible_collections/grafana
&& rm -rf ./.local/lib/python3.10/site-packages/ansible_collections/community/digitalocean
&& sudo apt install -y nodejs npm
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
&& . "$NVM_DIR/nvm.sh" && nvm install 20
&& sudo npm install npm@latest -g
because there were some vulns Snyk reported.
So please explain why is asking for dnf even so yum is the default pkg mgr for AL2 and also how those changes in the runner might impact this.
- name: "yum update". # this works
ansible.builtin.shell: 'yum update *'
become: true
type here# - name: 'Update all yum packages' # this doesn't
# ansible.builtin.yum:
# name: '*'
# state: latest
# become: true
If I add use_backend: yum the error persists
If I add use_backend: dnf it asks to install python3-dnf
Using the shell module doesn’t fix the root cause of the problem and it gets complicated for the selinux block and others so is not a solution.
Cristi23b is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.