What I do is just use a vagrant ssh --comand to get the output and pipe to 
a local file.  In our case we use puppet so the example uses "facter" but 
you can get the info anyway you want.

vagrant ssh --command "facter --json -p" > instancefacts.json
vagrant ssh --command "facter -p ipaddress" > ipaddress.txt

I can then load the ipaddress.txt or I can load the json and use it to get 
that data or get the dns name and much, much more. 

If you have ec2tools installed on your instance you could also use 
something like ec2-describe-instances or the myriad of other ec2 tools to 
get info about the system if setup properly.

As long as you are not using any "puts" in your vagrant that will mess up 
the output you can use this technique for just about anything.

I also add:

aws.ssh_host_attribute = :dns_name

to my aws vm provider.  This way the vagrant ssh will work from an internal 
ec2 network (I launch ec2 vagrant images from an existing ec2 instance) or 
from an external network if you launch it from a local server or desktop.

Thanks,

robo


On Tuesday, March 31, 2015 at 6:18:30 PM UTC-7, Amos S wrote:
>
> On Wednesday, 1 April 2015 09:58:52 UTC+11, Alvaro Miranda Aguilera wrote:
>>
>> It also should have the needed if you want to use scp/sftp directly 
>> using the same .pem 
>>
>
> The way I work with this right now (subject to possible later refactoring) 
> is that the Vagrant basebox is already very similar to our non-vagrant EC2 
> "golden AMI"'s and together with my general .ssh/config file it makes it 
> easy for me to "ssh aws-private-ip-address" and get onto any EC2 instance. 
> I just need the address.
>
> Here is what my .ssh/config look like:
>
> ForwardAgent yes
> IdentityFile ~/.ssh/id_rsa
> IdentityFile ~/.ssh/default-key-used-also-by-vagrant.pem
>
> Host 10.*
>     User ubuntu
>     UserKnownHostsFile /dev/null
>     StrictHostKeyChecking no
>
> With this config, I can do "ssh ip-address"/"scp ip-address"/"rsync 
> ip-address".
>
> Cheer,
>
> --Amos
>
>>
>> but not sure for AWS.. 
>>
>> On Wed, Apr 1, 2015 at 11:54 AM, Amos S <[email protected]> wrote: 
>> > Thanks. At least it contains the IP address. 
>> > 
>> > On Wednesday, 1 April 2015 09:46:28 UTC+11, Alvaro Miranda Aguilera 
>> wrote: 
>> >> 
>> >> perhaps vagrant ssh-config 
>> >> 
>> >> ? 
>> >> 
>> >> On Wed, Apr 1, 2015 at 10:56 AM, Amos S <[email protected]> wrote: 
>> >> > Hi, 
>> >> > 
>> >> > I use Vagrant mainly with AWS VPC right now. I frequently have to 
>> know 
>> >> > the 
>> >> > Vagrant box's IP address in order to run things like "curl" 
>> connecting 
>> >> > to it 
>> >> > from my laptop. 
>> >> > 
>> >> > I'm aware of "vagrant ssh" giving me an interactive shell on the box 
>> >> > itself, 
>> >> > but I want to be able to communicate with it directly from my 
>> laptop. 
>> >> > 
>> >> > Right now the only way I found is to lookup the instance in the AWS 
>> >> > console 
>> >> > (additional tags like "environment=vagrant", username and instance 
>> name 
>> >> > make 
>> >> > it easy to find). 
>> >> > 
>> >> > I was wondering whether there is already a way to query this 
>> information 
>> >> > from Vagrant itself, after all it uses this information heavily in 
>> order 
>> >> > to 
>> >> > ssh into the instance. 
>> >> > 
>> >> > What I have in mind is something like perhaps "vagrant status 
>> --long". 
>> >> > 
>> >> > Any thoughts? Am I missing something? 
>> >> > 
>> >> > Thanks. 
>> >> > 
>> >> > -- 
>> >> > 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