Hello Paul!

You are correct. Because the box has the same Vagrantfile, it gets loaded
twice when you run Vagrant (see
https://www.vagrantup.com/docs/vagrantfile/#load-order-and-merging)

I've been working this week to fix the bug in Vagrant, and I've put up a pull
request <https://github.com/mitchellh/vagrant/pull/8680> which will be
included in the next release. However, there is a workaround if you can't
wait. The bug itself is due to your provision block not having a name. If
you don't want them running twice, you can fix it by giving it a name like
this:

`config.vm.provision "my shell script", type: "shell", ....`

Then the script should only run once. Hopefully that helps!

Cheers.
- Brian Cain

On Fri, Jun 9, 2017 at 11:11 AM, Paul Hoffman <[email protected]>
wrote:

> Sorry for the long delay in getting back to you on this. I've been bashing
> my head against the desk and just now figured it out.
>
> The box has a Vagrantfile. That file has 'config.vm.provision "shell',
> path: "run_at_start.sh"" in it. The Vagrant machine *also* has the same
> Vagrantfile. Because of the way that Vagrant pulls in the box's Vagrantfile
> after parsing its own, it now has two (identical) 'config.vm.provision
> "shell' lines and it decides that I meant to run it twice.
>
> I could consider this a bug, but I can also see that "having two identical
> shell lines means run the command twice" is logical if you squint hard.
>
> I have a solution for my use case: remove the shell line from the
> machine's Vagrantfile. Hopefully this doesn't burn other people or, if it
> does, that they can find this thread.
>
> --Paul Hoffman
>
> On Wed, Jun 7, 2017 at 12:30 AM, Alvaro Miranda Aguilera <
> [email protected]> wrote:
>
>>
>> On Wed, Jun 7, 2017 at 12:02 AM, Paul Hoffman <[email protected]>
>> wrote:
>>
>>> Vagrant.configure("2") do |config|
>>>   config.vm.box = "main"
>>>   config.vm.provision "shell", path: "run_at_start.sh"
>>> end
>>>
>>
>> Hello
>>
>> It shouldn't.
>>
>> So I will suggest.
>>
>> 1. check with a different box, ie hashicorp/precise64
>>
>> 2. The way Vagrant works, you have 3 Vagrantfiles (if present) and they
>> get merge in memory.
>>
>> So check if there is a Vagrantfile at:
>>
>> ~/.vagrant.d/Vagrantfile  < this is a global one that will be loaded into
>> all the commands
>>
>> ~/.vagrant.d/boxes/<thebox>/<somepath>/Vagrantfile < this will be used
>> in all the VMs that use this base box.
>>
>> Also you can test with:
>>
>> #   config.vm.provision "shell", path: "run_at_start.sh"
>>   config.vm.provision "shell", inline: " echo we run run_at_start.sh"
>>
>> That will display how many runs will happen.
>>
>> If this display only one time, then maybe the script is calling himself?
>>
>> There aren't many options.
>>
>>
>>
>>
>> --
>> Alvaro
>>
>> --
>> 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/ms
>> gid/vagrant-up/CAHqq0ezUrhwB7bQtOcdVRjP4Bu2FW2KWVdq%
>> 2BvwD3GHXqz1_%2BPg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/vagrant-up/CAHqq0ezUrhwB7bQtOcdVRjP4Bu2FW2KWVdq%2BvwD3GHXqz1_%2BPg%40mail.gmail.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/CAPik8yYAfr%3DT_JtbK_rc4K0CDhpPOL%
> 3D0DAfJB2QCr%3DDj2RaH0A%40mail.gmail.com
> <https://groups.google.com/d/msgid/vagrant-up/CAPik8yYAfr%3DT_JtbK_rc4K0CDhpPOL%3D0DAfJB2QCr%3DDj2RaH0A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Brian Cain

-- 
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/CADHESCX%2Bji%2BK9XZL6n%2BS_2o%2BVu2Z9eSAwwg7T8LwHMXKq%3DmL4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to