Flatpak not installing via playbook

The following playbook doesn’t seem to work:

- hosts: localhost
tasks:
- name: Enable flathub repo
become: yes
command: flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
- name: Install MakeMKV
flatpak:
name: com.makemkv.MakeMKV
state: present
method: user

The output is as follows:

fatal: [localhost]: FAILED! => {“changed”: false, “command”: “/usr/bin/flatpak install --user -y flathub com.makemkv.MakeMKV”, “msg”: “Failed to execute flatpak command”, “rc”: 1, “stderr”: “error: No remote refs found similar to ‘flathub’\n”, “stderr_lines”: [“error: No remote refs found similar to ‘flathub’”], “stdout”: “Looking for matches…\n”, “stdout_lines”: [“Looking for matches…”]}

I thought these sections from the error was interesting, and confusing*:*

“/usr/bin/flatpak install --user -y flathub com.makemkv.MakeMKV”,

No remote refs found similar to ‘flathub

Why would it be trying to install ‘flathub’?

I’m new to Ansible, still learning. Any assistance would be greatly appreciated.

So I was told by a source that I should use flatpak_remote for adding my repo. It worked.

Here’s the final playbook that works:

- hosts: localhost
tasks:
- name: Add flathub repo
flatpak_remote:
name: flathub
state: present
flatpakrepo_url: https://dl.flathub.org/repo/flathub.flatpakrepo
method: user
- name: Install MakeMKV
flatpak:
name: com.makemkv.MakeMKV
state: present
method: user