大网数据广告活动
服务器运维问答

How to install RPM Fusion repository with Ansible on Fedora 32 Server virtual machine?

· 52CE 我爱测

I want to install RPM Fusion repository on Fedora 32 Server virtual machine with Ansible I've tried various possibility unsuccessfully : - name: Enable the RPM Fusion repository command: dnf install https://download1.rpmfusion.or…

问题原文

原帖链接 · Maxime · CC BY-SA 4.0

I want to install RPM Fusion repository on Fedora 32 Server virtual machine with Ansible

I've tried various possibility unsuccessfully :

- name: Enable the RPM Fusion repository
command: dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-    free-release-$(rpm -E %fedora).noarch.rpm
when: ansible_facts['os_family'] == 'Fedora' and ansible_facts['distribution_major_version'] == '32'

or

- name: Enable the RPM Fusion repository
  dnf:
    name: 'https://download1.rpmfusion.org/free/fedora/rpmfusion-    free-release-$(rpm -E %fedora).noarch.rpm'
    state: present
  when: ansible_facts['os_family'] == 'Fedora' and ansible_facts['distribution_major_version'] == '32'

Every time the task is skipped

TASK [Enable the RPM Fusion repository] *******************************************************************************
skipping: [my-ip-address]

Do you have an idea?

Thanks!

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

Don't use command to install packages. This has no hope of idempotence and will fail in various and subtle ways.

The reason these are skipped is that the os_family fact is never Fedora. It is set to RedHat on Fedora systems.

You should be checking for the distribution name directly:

when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int == 32

You've got further problems, though, and your dnf play will also fail, because you tried to use a shell substitution and Ansible won't do anything with that.

Your play should look more like this:

- name: Enable the RPM Fusion repository
  dnf:
    name: "https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-{{ansible_distribution_major_version}}.noarch.rpm"
    state: present
  when: ansible_distribution == 'Fedora'

We're actually providing the version number via substitution, so it will have "32" instead of a random shell command. And of course in this case there is no need to check the distribution version in when: because the relevant version is already provided in the package name.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-06-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。