Maybe you could take a step back and explain why you want to use (or test)
against localhost? You mentioned that you wanted to use ansible during
vagrant up, for instance, so I'm having trouble understanding why you'd
want to provision your host instead of your guest.

I'm provisioning a *guest* so I went with the simple `hosts: all` in the
playbook.yml

Also, I don't know if you'll need it or not, but in my Vagrantfile, I have:


    # Disable the new default behavior introduced in Vagrant 1.7, to
    # ensure that all Vagrant machines will use the same SSH key pair.
    # See https://github.com/mitchellh/vagrant/issues/5005
    config.ssh.insert_key = false






On Tue, Oct 10, 2017 at 11:12 AM, Ivan Adji-Krstev <[email protected]>
wrote:

> Hi all,
>
> I want to use Ansible during the creation of Vagrant Box or Vagrant UP. So
> i have the following configuration about it
>
> config.vm.provision "ansible_local" do |ansible|
>>   ansible.extra_vars = { HOSTS: "vagrantbox" }
>>   ansible.playbook = "/vagrant/httpd.yaml"
>> end
>
> And in the httpd.yaml file i have this
>
>> ---
>> - hosts: localhost
>>   vars:
>>     http_port: 80
>>   remote_user: root
>>   tasks:
>>   - name: ensure apache is at the latest version
>>     yum: name=httpd state=latest
>>   - name: ensure apache is running (and enable it at boot)
>>     service: name=httpd state=started enabled=yes
>
>
> So when i run the Vagrant up from the directory where i have Vagrant file
> and httpd.yaml file i got this error from Ansible
>
>>     default: Running ansible-playbook...
>> PLAY [localhost] ******************************
>> *********************************
>> skipping: no hosts matched
>> PLAY RECAP ************************************************************
>> *********
>
>
> Now the interesting part is that when i do vagrant ssh and try to execute
> the same playbook, it works. It does not give me a problem.
> Yes this is ansible executing the playbook locally for testing.
>  Also i want to use ansible-pull but still have the same problem.
>
> Its not the problem installation of the httpd i know i can do it with
> vagrant, i want to do something with Ansible and i start this simple test.
>
> Can someone tell me how can i force ansible to work with localhost.
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/vagrant-up/44fac18b-4c28-407b-9b7e-c1a82fdf825a%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/44fac18b-4c28-407b-9b7e-c1a82fdf825a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CA%2BonWPcA0eH5J2Oy5Ea-i1a_1suyYx%2BOgrhG8rMyQ_9ovDW2LA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to