Specify/Obtain Hostname?

31 views
Skip to first unread message

mich...@globalcustomcommerce.com

unread,
Jun 2, 2017, 8:25:46 AM6/2/17
to Packer
I am wanting to run some serverspec tests against my vagrant box but i'm not really sure how to get the virtualmachines hostname from packer or how to configure a hostname.  Anyone know if this i possible?

Rickard von Essen

unread,
Jun 2, 2017, 8:41:11 AM6/2/17
to packe...@googlegroups.com
I'm not sure why you need the hostname?

But if you need to get that to the machine running Packer you can do something like:

"provisioners": [
  {
    "type": "shell",
    "inline": [ "hostname > /tmp/hostname" ]
  },
  {
    "type": "file",
    "direction": "download",
    "source": "/tmp/hostname",
    "destination": "hostname"
  }
]

And you will get the hostname in the file "hostname".

On 2 June 2017 at 14:25, <mich...@globalcustomcommerce.com> wrote:
I am wanting to run some serverspec tests against my vagrant box but i'm not really sure how to get the virtualmachines hostname from packer or how to configure a hostname.  Anyone know if this i possible?

--
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/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/4328edb6-bd18-40b6-81f3-73f9aa61fd4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mich...@globalcustomcommerce.com

unread,
Jun 2, 2017, 8:45:08 AM6/2/17
to Packer
Thanks i Will give this a shot.  The reason i want it is my build agent is building the packer image.  Afterwards i want to use serverspec to winrm and run some verfication tests against the box.  In order to do this i must specify the hostname of the box


On Friday, June 2, 2017 at 7:41:11 AM UTC-5, Rickard von Essen wrote:
I'm not sure why you need the hostname?

But if you need to get that to the machine running Packer you can do something like:

"provisioners": [
  {
    "type": "shell",
    "inline": [ "hostname > /tmp/hostname" ]
  },
  {
    "type": "file",
    "direction": "download",
    "source": "/tmp/hostname",
    "destination": "hostname"
  }
]

And you will get the hostname in the file "hostname".
On 2 June 2017 at 14:25, <mich...@globalcustomcommerce.com> wrote:
I am wanting to run some serverspec tests against my vagrant box but i'm not really sure how to get the virtualmachines hostname from packer or how to configure a hostname.  Anyone know if this i possible?

--
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/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

mich...@globalcustomcommerce.com

unread,
Jun 2, 2017, 9:20:04 AM6/2/17
to Packer
Unfortunately i'm using winrm and it doesn't support downloading of files


On Friday, June 2, 2017 at 7:41:11 AM UTC-5, Rickard von Essen wrote:
I'm not sure why you need the hostname?

But if you need to get that to the machine running Packer you can do something like:

"provisioners": [
  {
    "type": "shell",
    "inline": [ "hostname > /tmp/hostname" ]
  },
  {
    "type": "file",
    "direction": "download",
    "source": "/tmp/hostname",
    "destination": "hostname"
  }
]

And you will get the hostname in the file "hostname".
On 2 June 2017 at 14:25, <mich...@globalcustomcommerce.com> wrote:
I am wanting to run some serverspec tests against my vagrant box but i'm not really sure how to get the virtualmachines hostname from packer or how to configure a hostname.  Anyone know if this i possible?

--
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/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.

Rickard von Essen

unread,
Jun 2, 2017, 9:45:24 AM6/2/17
to packe...@googlegroups.com
Ok, then you will be happy when the next release comes out. https://github.com/hashicorp/packer/pull/4748

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/8bcbe9fd-edfa-4915-9ca0-ff568c50c235%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages