“skipping: no hosts matched” issue with Vagrant and Ansible

前端 未结 9 1150

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

相关标签:
9条回答
  • 2021-02-05 03:20

    I tried pointing the groups to default vagrant box and it worked. Refer https://gagor.pl/2015/12/ansible-on-vagrant-skipping-no-hosts-matched/

    ansible.groups = {
      'webservers' => ['default']
    }
    
    0 讨论(0)
  • 2021-02-05 03:23

    You can run your playbook in verbose mode by adding -vvvv in the end. Ansible uses host file from /etc/ansible/hosts add the below

    You can check what inventory file is being used by your ansible by below

    ansible --version
    ansible 2.0.0.2
    config file = /etc/ansible/ansible.cfg
    configured module search path = Default w/o overrides
    

    Then check your host file if it contains the exact group for host

     vim /etc/ansible/hosts
     [webserver1]
     IP of machine
    

    check by running the below command

    ansible -m ping 10.0.3.145 (IP Of machine)
    10.0.3.145 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
    

    }

    This should fix the issue.

    0 讨论(0)
  • 2021-02-05 03:34

    It could help to post your Vagrantfile and your ansible inventory file.

    • Are you using the default ansible provider of vagrant?

      did you specify the inventory_path?

     config.vm.provision :ansible do |ansible|
       ansible.playbook = "provisioning/playbook.yml"
       ansible.inventory_path = "provisioning/ansible_hosts"
     end
    
    • Are you launching it the through the a vagrant ssh with --connection=local try a /etc/ansible/hosts
    [webserver1]
    127.0.0.1              ansible_connection=local
    
    • Are you using the ansibleLocal provider / vagrant plugin?
    0 讨论(0)
提交回复
热议问题