Sorry, I just realized you're using the "ansible_local" provisioner; I
forgot that existed. I've only used the "ansible" provisioner, so that's
why I was confused. Hopefully, someone with actual "ansible_local"
experience can help.

On Tue, Oct 10, 2017 at 6:12 PM, Ivan Adji-Krstev <iadjikrs...@gmail.com>
wrote:

> Hi Jamie,
>
> What i want to do is, to have is when the VagrantBox is up or bring up,
> from the inside of the box, i want Ansibe to make pull or execute the
> playbook.yml file on the VM (VagrantBox/Guest). I'm using Vagrant to build
> the VM, and i want Ansible to play role as Pull or to execute locally the
> playbook. I'll take the ssh.insert_key parameter, but i'm having problem to
> execute this playbook.yml file locally which is working if i execute after
> the VM is up and running but not when i build the VM.
>
> I think the problem is that when you build the Vagrant Box, the Ansible
> take the default host file and search for the localhost information,
> instead of the playbook.yml or something. Its executing with parameters or
> something similar.
>
> I try to use host all but i got this error:
>
>     default: Running ansible-playbook...
>> PLAY [all] ************************************************************
>> *********
>> TASK [Gathering Facts] ******************************
>> ***************************
>> ok: [default]
>> TASK [ensure apache is at the latest version]
>> **********************************
>> fatal: [default]: FAILED! => {"changed": true, "failed": true, "msg":
>> "You need to be root to perform this command.\n", "rc": 1, "results":
>> ["Loaded plugins: fastestmirror\n"]}
>>         to retry, use: --limit @/vagrant/httpd.retry
>> PLAY RECAP ************************************************************
>> *********
>> default                    : ok=1    changed=0    unreachable=0
>> failed=1
>> Ansible failed to complete successfully. Any error output should be
>> visible above. Please fix these errors and try again.
>
>
> Also the main part here is to use Ansible-Pull which pull the yaml file
> from Git Repo and then execute locally. But if i can work around with this
> ill work around with pull to.
>
> On Tuesday, October 10, 2017 at 10:34:21 PM UTC+2, Jamie Jackson wrote:
>>
>> 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 <iadji...@gmail.com>
>> 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 vagrant-up+...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/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 vagrant-up+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/vagrant-up/0b65e7f3-5c6c-4d0a-a104-4e69bf904113%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/0b65e7f3-5c6c-4d0a-a104-4e69bf904113%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 vagrant-up+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CA%2BonWPdNZ%2B6kdB5uON9TmFqrDa5JNyr4%3DkYjaKQmo65TKK%3DJWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to