Ansible on Vagrant – skipping: no hosts matched

I have some Ansible roles to configure my vps, Raspberry Pi, etc. I like to test them before I broke something on my real, not clustered machines – I use Vagrant for that.
But with it I had one problem – in playbooks I define hosts as groups of severs ex. web for my vps:

- hosts: web
  gather_facts: True
  sudo: True

But testing machine wasn't in this group and when I run vagrant I could only see:

$ vagrant provision
==> default: Running provisioner: fix-no-tty (shell)...
    default: Running: inline script
==> default: Running provisioner: ansible...

PLAY [web] ******************************************************************** 
skipping: no hosts matched

PLAY RECAP ********************************************************************

To get rid of this I have to add default vagrant machine to my web group in Vagrantfile:

  config.vm.provision 'ansible' do |ansible|
    ansible.groups = {
      'web' => ['default']

    ansible.sudo = true
    ansible.limit = 'all'
    ansible.playbook = 'web.yml'

And that solved my problem 🙂

One thought on “Ansible on Vagrant – skipping: no hosts matched”

  1. Hi
    Tank you for solution, I had a same problem
    I added
    ansible.groups = {
    ‘web’ => [‘default’]
    in Vagrandfile . fixed my error


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.