Hello

There was an old email once that used ruby magic to detect if the id of the
vm existed, but i don't think is needed.

check for a local file, if doesn't exist, set those values.

and in a provision script, just do `touch /vagrant/.provisioned` or similar.

will be more easy to read.

My 2 cents

alvaro.

On Wed, Nov 15, 2017 at 3:42 PM, Sam Kaplan <stkap...@gmail.com> wrote:

> Not quite...I'm not worried about provisioning scripts in this case.
>
> I have a block in my Vagrantfile like:
>
>   config.vm.provider "virtualbox" do |vb|
>     vb.cpus = ENV["VAGRANT_CPU"] || "2"
>     vb.memory = ENV["VAGRANT_MEM"] || "2048"
>   end
>
> so you can specify cpu and memory size in environment variables. But this
> also means you have to specify them every time you boot the machine, or
> they will get overwritten by the defaults. If I had a way to detect that
> the machine was already created, then I could avoid setting the config
> values in that case.
>
> Thanks,
> Sam
>
> On Wednesday, November 15, 2017 at 3:46:37 AM UTC-5, Alvaro Miranda
> Aguilera wrote:
>>
>> Hello
>>
>> By default provisioning scripts only run at creation time.
>>
>> Next time you do vagrant up/reload the provisioning doesn't run at all.
>>
>> If there are some provisioning you want to have always to run, you can
>> add
>>
>> ,run: "always"
>>
>>
>> Does this helps?
>> Alvaro
>>
>> On Mon, Nov 13, 2017 at 9:50 PM, Sam Kaplan <stka...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> In a Vagrantfile, is it possible to detect whether a machine is already
>>> created? I'm trying to run a block of code only if "vagrant up" is creating
>>> a new box (and not when re-booting an existing one).
>>>
>>> Even a provider-specific method would be helpful -- I'm only using
>>> Virtualbox.
>>>
>>> Thanks,
>>> Sam
>>>
>>> --
>>> 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/c3ef20a6-5ef1-4253-a076-43d381bda8fe%40googlegroups.com
>>> <https://groups.google.com/d/msgid/vagrant-up/c3ef20a6-5ef1-4253-a076-43d381bda8fe%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> 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 vagrant-up+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/vagrant-up/824fbc3f-d644-4230-bc95-a425543aca49%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/824fbc3f-d644-4230-bc95-a425543aca49%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
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 vagrant-up+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CAHqq0eysO_gcTMrQX3rzqSAoxm8MpmxEsBU6wSHWTeMDaLC_CA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to