[Ansible Playbook] string passed as argument error

There seems to be something wrong with the input on this:

---
- hosts: localhost
  tasks:
    - name: Enabling third party repos
      become: true
      become_user: root
      dnf:
        state: present
        name:
         - fedora-workstation-repositories
    - name: Installing the RPM Fusion free repository
      dnf:
        state: present
        name:
        - https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
    - name: Installing the RPM Fusion non-free repository
      dnf:
        state: present
        name:
        - https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm

This is the error:

fatal: [localhost]: FAILED! => {"changed": false, "msg": "It appears that a space separated string of packages was passed in as an argument. To operate on several packages, pass a comma separated string of packages or a list of packages."}

Can someone help me? Thanks :blush:

2 Likes

Avoid using shell expressions, or try to quote the URLs, or use a supported Ansible method to pass variables.

1 Like

Hmmm… I tried quoting them now and it still won’t work. What’s an alternative to install the repos for the current version?

Try replacing $(...) with full URL.

1 Like

That worked, thanks! Btw, why isn’t it possible to do so, even quoting the line?

1 Like

It requires to invoke a subshell to expand the $(...) expressions which Ansible might not support.