I have installed Vagrant, VirtualBox and Ansible and trying to run provision over one host but it always returns \"skipping: no hosts matched\"
The head of my playbook f
Changing hosts to "all" worked for me.
---
- hosts: all
user: vagrant
sudo: yes
Make sure you're running ansible-playbook command instead of pure ansible command.
The first thing that jumps out at me is that the syntax on the head of your playbook file is incorrect, (it has extra dashes where it shouldn't). It should look like this instead:
---
- hosts: webservers
user: vagrant
sudo: yes
I think you can also do this without a hosts file, by assigning the Ansible groups in your Vagrant file.
If you don't have multiple machines in your Vagrant file your box will probably be called "default" and you will be able to add multiple Ansible groups with the following code.
Code:
config.vm.provision "ansible" do |ansible|
ansible.groups = {
"webservers" => ["default"],
"dev_enviroment" => ["default"]
}
ansible.playbook = "provisioning/playbook.yml"
end
make sure you use this command "ansible-playbook -i yourhosts your.yml"
According to the vagrant documentation (http://docs.vagrantup.com/v2/provisioning/ansible.html), when you use Ansible to provision, vagrant will automatically create an host file named vagrant_ansible_inventory_default
which will use vagrant vm.config
information (like your VM IP, remote ssh port).
So just add your playbook path using the ansible.playbook = "playbook.yml"