Hello,

Thats because by default the scripts run with privileged mode, so run as 
root.

if you want to setup variables as vagrant, then you need to the script with 

, privileged: "false"

https://www.vagrantup.com/docs/provisioning/shell.html



On Friday, April 8, 2016 at 1:01:34 PM UTC+12, Kunal Pariani wrote:
>
> Thanks but i did update the script & still don't see the env var HOST_IP 
> being set
>
> Kunals-MacBook-Pro-2:consul-demo kunalpariani$ vagrant provision
> ==> default: Running provisioner: shell...
>     default: Running: inline script
> ==> default: stdin: is not a tty
> ==> default: var HOST_IP=10.2.2.70
> ==> default: Running provisioner: shell...
>     default: Running: 
> /var/folders/5m/48h7dsrx39x2vl_xqmlddtch0000gn/T/vagrant-shell20160407-77458-1i6snef.sh
> ==> default: stdin: is not a tty
> ==> default: HOST_IP=10.2.2.70
> *==> default: export HOST_IP=10.2.2.70*
> ==> default: $1=arg1
> ==> default: Running provisioner: ansible...
> -----------------------------
> $ vagrant ssh
> Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-85-generic x86_64)
>
>  * Documentation:  https://help.ubuntu.com/
>
>   System information as of Fri Apr  8 00:52:27 UTC 2016
>
>   System load:  0.48              Users logged in:        0
>   Usage of /:   5.8% of 39.34GB   IP address for eth0:    10.0.2.15
>   Memory usage: 28%               IP address for eth1:    10.2.2.70
>   Swap usage:   0%                IP address for docker0: 172.17.0.1
>   Processes:    85
>
>   Graph this data and manage this system at:
>     https://landscape.canonical.com/
>
>   Get cloud support with Ubuntu Advantage Cloud Guest:
>     http://www.ubuntu.com/business/services/cloud
>
> 120 packages can be updated.
> 57 updates are security updates.
>
>
> Last login: Fri Apr  8 00:53:38 2016 from 10.0.2.2
> vagrant@vagrant-ubuntu-trusty-64:~$
> vagrant@vagrant-ubuntu-trusty-64:~$ echo $HOST_IP
>
> vagrant@vagrant-ubuntu-trusty-64:~$ vi ~/.bash
> .bash_history  .bash_logout   .bashrc
>
> No .bash_profile here
> ----------------
> $ cat provision.sh
> #!/bin/bash
>
> if [ ${HOST_IP} ]; then
> echo "HOST_IP=${HOST_IP}"
> *echo "export HOST_IP=${HOST_IP}" | tee -a ~/.bash_profile*
> else
> echo "var HOST_IP not set"
> fi
>
> if [ ${1} ]; then
> echo "\$1=${1}"
> fi
>
> On Thursday, April 7, 2016 at 4:04:42 PM UTC-7, Alvaro Miranda Aguilera 
> wrote:
>>
>>
>> On Fri, Apr 8, 2016 at 8:52 AM, Kunal Pariani <[email protected]> wrote:
>>
>>> ==> default: HOST_IP=10.2.2.70
>>
>>
>> Hello.
>>
>>
>> this line:
>> ==> default: HOST_IP=10.2.2.70
>>
>> Means the variable you are passing if being handled by the script.
>>
>> From there, you need to update the provision script to configure it in 
>> the way you want.
>>
>> Vagrant is doing his share, is upto configure the guest to consume that 
>> var.
>>
>> You could replace this:
>> *export HOST_IP=${HOST_IP}*
>>
>> *with*
>>
>> *echo "export HOST_IP=${HOST_IP}" | tee -a ~/.bash_profile*
>>
>> *Now,*
>>
>> *a piece of information, if you are using virtualbox, the host always 
>> will be available as 10.0.2.2*
>>
>>
>>
>>
>> *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/msgid/vagrant-up/b215b4c5-0653-4ba9-a407-14fea84ce083%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to