[chef] Re: custom json attributes to powershell variables


Chronological Thread 
  • From: Greg Zapp < >
  • To:
  • Subject: [chef] Re: custom json attributes to powershell variables
  • Date: Thu, 5 Jun 2014 01:44:14 +1200

Hi Simon,

-j would be correct but it takes a JSON string: '{ "ip_address" : "10.x.x.x", "prefix" : 24, "gateway" : "10.x.x.x" }'

After that, assuming you have knife bootstrap working with Windows, you should be able to use string interpolation inside a HEREDOC to craft your powershell command/script with the attributes: https://gist.github.com/ProTip/a2301025cfc4d8b9500f

Cheers,
   -Greg


On Thu, Jun 5, 2014 at 1:20 AM, Greg Zapp < " target="_blank"> > wrote:
Hi Simon,

Is your difficulty with getting the attributes into Chef or using them once they are there?

-Greg


On Wed, Jun 4, 2014 at 9:36 PM, < " target="_blank"> > wrote:
Hi,

Do you know how I would be able to save JSON custom attributes to a powershell
variable in a recipe?

When I bootstrap a Windows machine I would like to pass the IP, Subnet, GW and
DNS Servers into custom attributes and when the recipe is applied, the windows
machine sets the correct information to the network card (using powershell).

Since knife vsphere doesn't currently support vmware windows customisations I
can't think of another way.

So I would end up with something like this in the recipe (which is a powershell
script):

$ipAddress = customIPAttribute
$gateway = customGWAttribute
etc, within the recipe.

Cheers,
Simon.





Archive powered by MHonArc 2.6.16.

§