Ansible-galaxy and shell provider

Hi, everyone!

I’m having issue when running this chunk of code.

  config.vm.define "control" do |r|
    r.vm.provider "virtualbox" do |vb|
      vb.name = "control"
    end
    r.vm.hostname = "ans-control"
    r.vm.provision "shell", inline: <<-SHELL
      dnf install epel-release -y
      dnf install ansible -y
      ansible-galaxy collection install community.general
    SHELL
end

The issue is with “ansible-galaxy collection install” command. It seems to be running well and fine without any errors on Vagrant’s end, but when I try to run my playbook, which is using a module from community.general I get the following error.

ERROR! couldn't resolve module/action 'community.general.iptables_state'. This often indicates a misspelling, missing collection, or incorrect module path.

It gets resolved by manually running the command on my control node, but I wonder if it can be solved using automation.

Here is a link to a full version of my project on Github, Vagrantfile included.
Would greatly appreciate your help.
https://github.com/alex4lbin/vagrant-labs/tree/main/ansible-lab

PS: I know that you can use Ansible as a Vagrant provider, but I am not looking for that kind of solution.