Hello there, seems I find something you can test.

This is the commint when --no-provision was enabled.

https://github.com/mitchellh/vagrant/commit/1770ad1ee5c45eb46c0d1d70e9ec8ffb3bbc48f6

so, can you check env["provision.enabled"] ?

Here someone whote a custom provider, that may help you write something you
need

https://github.com/mitchellh/vagrant/issues/591



The magic:

   14

+          # We set this here so that even if this value is changed in
the future,

     15

+          # it stays constant to what we expect here in this moment.

     16

+          enabled = env["provision.enabled"]

     17

+          if enabled

     18

+            # Instantiate and prepare the provisioners. Preparation
must happen here

     19

+            # so that shared folders and such can properly take effect.

     20

+            provisioners = enabled_provisioners

     21

+            provisioners.map { |p| p.prepare }

     22

+          end




On Mon, Mar 31, 2014 at 10:45 AM, Alvaro Miranda Aguilera <[email protected]
> wrote:

> Hello there,
>
> got it, on the host.
>
> for the multiple running thing, which if found also, I did a dirty trick.
>
> Icreated a variable:
>
> #variable used to provide information only once
> give_info ||=true
>
> then inside the provider :virtualbox block i did
>
>             unless give_info==false
>               puts "on first boot shared disks will be created, this will
> take some time"
>               give_info=false
>
> to execute that only once every time the Vagrant file is readed.
>
> As for the provision, I am not sure how check how to know if we are in a
> provision call or no..
>
> We may want to look at the provisioner code.. what ever you find, please
> report back!
>
> Alvaro.
>
>
>
> On Sun, Mar 30, 2014 at 8:14 PM, <[email protected]> wrote:
>
>> Hello, Alvaro,
>>
>> Thanks for your response, but both options don't work for me:
>>
>> 1. Even if you call a ruby function/command inside the provider-specific
>> block, the function/command is executed (and multiple times) for any
>> provider.
>>
>>    # VirtualBox provider-specific configuration
>>    server.vm.provider :virtualbox do |vb|
>>       vb.landrush.enable
>>       puts "Hello: my provider is VirtualBox"
>>    end
>>    In the example below, the message "Hello: my provider is VirtualBox"
>> is printed a few times even if I start vagrant with the following command:
>>    *vagrant up --provider softlayer*
>>
>> 2. Here, I want to run the ruby script (or ruby function) on the local
>> machine and *NOT* on the guest machine, thus your idea does not work for
>> me.
>>
>> Actually, I want to run a ruby script which prepares a dynamic file in
>> the sync directory for the provision script. Thus, I want to run the script
>> locally just before the provisioning.
>>
>>
>>
>> Regards,
>>
>> -- Idan
>>
>>
>> On Friday, March 28, 2014 1:53:41 AM UTC+2, Alvaro Miranda Aguilera wrote:
>>
>>> hello,
>>>
>>> for q1, I have seen things like this:
>>>
>>>   config.vm.provider :vmware_fusion do |vb, override|
>>>
>>>     override.vm.box_url = 
>>> "http://storage.core-os.net/coreos/amd64-usr/alpha/coreos_production_vagrant_vmware_fusion.box";
>>>
>>>   end
>>>
>>> perhaps you can test inside a data block like that?
>>>
>>> for 2, you mean ruby script as  script.rb? if yes, then the shell inline
>>> will be executed only when the machine is provisioned
>>>
>>> you can copy the script into the guest, and execute it like:
>>>
>>> config.vm.provision :file, :source => "/path/myawesomescript",
>>>
>>>   :destination => "/myawesomescript"
>>>
>>> config.vm.provision :shell, :inline => "ruby /myawesomescript"
>>>
>>> Alvaro.
>>>
>>>
>>>
>>> On Fri, Mar 28, 2014 at 12:28 AM, <[email protected]> wrote:
>>>
>>>> Hi,
>>>>
>>>> I've a single Vagrantfile that is used for multiple providers (e.g.,
>>>> VirtualBox, Softlayer, etc).
>>>>
>>>> 1. I would like to call a different ruby script (or ruby function) for
>>>> each profvider from the Vagrantfile. How I can check the provider in the
>>>> Vagrantfile ?
>>>>
>>>> 2. In addition, I would like to run the ruby script if and only if the
>>>> provision flag is set. That is, if vagrant is NOT executed with the
>>>> --no-provision flag. How I can check the provision flag in the Vagrantfile 
>>>> ?
>>>>
>>>> Thanks In Advance,
>>>>
>>>> -- Idan Zach
>>>>
>>>> --
>>>> 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].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  --
>> 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].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to