For test purposes I've configured a combination of vagrant/virtualbox/ansible.
Versions >> Ansible : 2.3.1.0 | Vagrant : 1.9.5.
While running :
vagrant provision
the output states :
web1: Running provisioner: ansible...
web1: Running ansible-playbook...
PLAY [Install Apache]
**********************************************************
skipping: no hosts matched
PLAY RECAP
****************************************************************
Below the configuration files :
Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.define "web1"
config.vm.network "private_network", type: "dhcp"
config.vm.network "forwarded_port", guest: 8040, host: 8090
config.vm.provider "virtualbox" do |vb|
vb.memory = "256"
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provisioning/playbook.yml"
end
end
end
Playbook :
---
- name: Install Apache
hosts: testclients
become_user: root
roles:
- apache
Andible inventory (/etc/ansible/hosts) :
[testclients]
testclient3
and successful checking
ansible -m ping testclients
testclient3 | SUCCESS => {
"changed": false,
"ping": "pong"
}
The weird thing is that if i will run the playbook itself (ansible-playbook playbook.yml) it works, in contrary inside vagrant which doesn't and return "no hosts matched". Any help would be appreciated.