Re: [packer] resetting network interface before saving image

2019-10-16 Thread Rickard von Essen
See this code
https://github.com/chef/bento/blob/master/packer_templates/centos/scripts/cleanup.sh#L15

On Thu, Oct 17, 2019, 02:31 Mauricio Tavares  wrote:

> So I have packer create a centos image, but when it saves (creates) it, it
> saves the old mac address, associating it with the default interface. Is
> there a way to remove that so when I create a vm guest based on said image
> it will configure the default interface based on whatever mac/uuid it is
> given?
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/455a2eeb-57e3-4192-8e85-21443edcf97e%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt9HH3TTJPSF4KgT%2BQgZMpz%2BVdhmWLsvt_3BxqwpE2qMug%40mail.gmail.com.


[packer] resetting network interface before saving image

2019-10-16 Thread Mauricio Tavares
So I have packer create a centos image, but when it saves (creates) it, it 
saves the old mac address, associating it with the default interface. Is 
there a way to remove that so when I create a vm guest based on said image 
it will configure the default interface based on whatever mac/uuid it is 
given?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/455a2eeb-57e3-4192-8e85-21443edcf97e%40googlegroups.com.


Re: [packer] Passing Tags & Run_tags Blocks in var-file : Is This Possible?

2019-10-16 Thread Jimster
Rickard,

Appreciate the prompt reply.

With that in mind, I'll probably use Powershell scripting or AWS CLI in the 
Providers section to set the tags, using a specific tag file to read from , 
for the relevant build.

Jim

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/ac1cb8b3-b4de-4f89-953d-e591752a1c6f%40googlegroups.com.


[packer] updating Windows's path between PowerShell provisioners, for both WinRM and SSH communicators

2019-10-16 Thread Sébastien Barthélémy
Hello,

I'm running powershell scripts with:

  "provisioners": [{ "type": "powershell", "scripts": [ 
"scripts/step1.ps1", "scripts/step2.ps1", "scripts/step3.ps1" ]}]

I would like binaries added at one step to be callable (ie available in the 
path) from the next one.
It is the case when I use the WinRM communicator, but not the SSH 
communicator.
When using the SSH communicator, it seems I would need to restart the ssh 
service between each step to get the path updated, which would defeat 
packer's nice orthogonality.

Is there is recommended solution? I could restart the whole VM between each 
step, but it looks wasteful.

(sorry if the answer is obvious, I'm by no way an experienced Windows 
admin) 





Here is the more complete story.

I'm using packer to setup Windows build slaves.
Provisioning involves installing package managers and then using them to 
install build tools.

Typically, it involves 3 steps

1/ install chocolatey,
2/ use cholocatey to install python
3/ use python's pip to install cmake

For step 2/ to work, the choco command installed at step 1/ must be 
available in the path.
Similarly, for step 3/ to work, the pip command installed at step 2/ must 
be available in the path.

PowerShell does not seem to update the path on the go, so I had to put 
those steps in distinct scripts, and run all of them in a powershell 
provisioner:

  "provisioners": [{ "type": "powershell", "scripts": [ 
"scripts/step1.ps1", "scripts/step2.ps1", "scripts/step3.ps1" ]}]

It works great when using the WinRM communicator (with the amazon-ebs 
builder):
each script seems to run in a different PowerShell invocation, using an 
updated path.

(The actual template is a bit more complicated and can be seen there
https://gitlab.com/sbarthelemy/conan-public-recipes/blob/master/ci/packer/gitlabrunner-win2016.json)

I'm now trying to add a vagrant builder to the template, using the SSH 
communicator (which is the only one supported by this builder)
It fails, because the path is not updated between each of the scripts.

I need to call "Restart-Service sshd" then to reconnect through SSH to see 
the updated path.

Best regards,
Sebastian

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/28b89563-b216-4a4a-9be2-df9ee9c32214%40googlegroups.com.


Re: [packer] How to fix 'Permission denied error'?

2019-10-16 Thread Rickard von Essen
It should be "sudo bash -c 'echo \'$PreserveFQDN on\' >>
/etc/rsyslog.d/server.conf'"

On Wed, Oct 16, 2019, 04:44 Anil Wadghule  wrote:

> When I have following config
>
> {
> "type": "shell",
> "inline":[
> "sudo echo '$PreserveFQDN on' >>
> /etc/rsyslog.d/server.conf”,
> ]
>  } ] }
>
> I get this error
>
> ==> amazon-ebs: /tmp/script_1019.sh: 27: /tmp/script_1019.sh: cannot
> create /etc/rsyslog.d/server.conf: Permission denied
>
> I know sudo mv a local file would fix that, but I don’t want to copy whole
> server.conf locally and move.
>
> cannot create /etc/rsyslog.d/server.conf: Permission denied
>
> Thanks,
> Anil
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/7F5A79E0-003D-4986-9087-F78BE0A0A529%40gmail.com
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt8W9HRNDQXUZp9L1KUdTgDef%3DjZD0tmwvJAbjZa-nJ1XQ%40mail.gmail.com.


Re: [packer] Passing Tags & Run_tags Blocks in var-file : Is This Possible?

2019-10-16 Thread Rickard von Essen
No, currently this is not supported. Only single values and arrays work.

On Wed, Oct 16, 2019, 10:31 Jimster  wrote:

> Hi,
>
> Been tasked with cleaning up packer code to remove duplication of explicit
> values in our working  build .json files - and use a few general
> *var-files* that will contain the relevant DEV, TEST and PROD instance
> types, vpc details, disk sizes etc.
>
> One of the builders sections we use are *tags *(and *run_tags*) of the
> format:
>
> "run_tags": {
>"Environment":  "DEV",
>"Application":  "Dave",
>"Tier": "Web App",
>"Function": "Dev Dave Web App",
>"Version":  "1.0",
>"CostCentre":   "0300 3246",
>"BusinessUnit": "AppServices",
>"Project":  "DaveMigration to AWS",
>"Product":  "IIS Server for Dave",
>"SupportEmail": "d...@dave.com",
>"ComplianceDomain": "YES",
>"DataClass":"5",
>"ProvisionedBy":"Packer",
>"ProvisionedWho":   "d...@dave.com",
>"ProjectName":  "Dave",
>"Name": "Dave Dev Web Box"
>},
>
> I'm not sure if or how I can include these arrays in a var-file.  Ideally
> the build file wants to refer to these as some kind of user variable e.g.
> in line with the usual ones:
> "builders": [{
>"type": "amazon-ebs",
>
> "region":   "{{ user `DEV_server_region`}}",
>"source_ami":   "{{ user `DEV_server_source_ami`}}",
> *"tags": "{{ user `DEV_dave_tags`}}",  <== WHATEVER
> FORMAT THIS SHOULD BE IN FOR A TAG BLOCK (Array?)*
>"instance_type":"{{ user `DEV_server_instance_type`}}",
>"winrm_use_ssl":true,
>"winrm_insecure":   true
>}],
>
> I've tried to capture these tag arrays in the var-file as so (snippet):
> ...
>
> "PROD_server_user_data_file":   "./USERDATA2.0.txt",
>
> "CA_server_run_tags": [{
>"Environment":  "DEV",
>"Application":  "Dave",
>"Tier": "Web App",
>"Function": "Dev Dave Web App",
>"Version":  "1.0",
>"CostCentre":   "0300 3246",
>"BusinessUnit": "AppServices",
>"Project":  "DaveMigration to AWS",
>"Product":  "IIS Server for Dave",
>"SupportEmail": "d...@dave.com",
>"ComplianceDomain": "YES",
>"DataClass":"5",
>"ProvisionedBy":"Packer",
>"ProvisionedWho":   "d...@dave.com",
>"ProjectName":  "Dave",
>"Name": "Dave Dev Web Box"
> }]
>
>
> But I get:
> packer validate -var-file .\dave_vars.json .\build_var_test_Dave.json
> invalid value ".\\dave_vars.json" for flag -var-file: Error reading
> variables in '.\dave_vars.json': json: cannot unmarshal array into Go value
> of type string
>
> Can someone please advise on how best to include (if possible) these tags
> and run_tags arrays into the var-file *and* refer to the resulting user
> array variable properly in the builder file?
>
> Thanks,
> Jimster
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/8975abcb-e431-4005-8e76-b40f6b048e8f%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/CALz9Rt-5-EBD%2Bhjv4jZbN3EJHaUxUuGwsF6nZ2jErDJ07vqa4A%40mail.gmail.com.


[packer] Re: How to create a Packer Windows image with winrm enabled ? (azure)

2019-10-16 Thread Jimster
Also - you are calling your Bootstrap *twice*.

Once in the Builders section (because you have user_data_file set) and then 
again in the Provisioners section:
{
"type": "powershell",
"scripts": "{{user `file_source`}}/Bootstrap-winrm.ps1"
},{...

You don't need to do it twice, it will probably interrupt any WinRM chat 
you were doing in the user_data_file connection.

On Wednesday, 28 August 2019 07:41:40 UTC+1, Sim wrote:
>
> Hi, 
>
> I am currently running into an issue that my Terraform could not connect 
> back to the VM it provisioned in order to connect to Chef server (via chef 
> provisioner) because it could not establish a connection to the VM. I think 
> it might be because the Packer image that I used in Terraform has not been 
> enabled for the winrm. I have looked around on the internet, but still 
> could not find out a good way to enable winrm in the packer. 
> I have tried to call a powershell file in the Packer template. The PS 
> script has a bunch of PS commands that enable winrm. But it didnt work when 
> I ran Packer build. 
>
> What I have tried:
> #bootstrap-winrm.ps1
> # Set administrator password
> net user admin admin12
> wmic useraccount where "name='admin'" set PasswordExpires=FALSE
>
> # First, make sure WinRM can't be connected to
> netsh advfirewall firewall set rule name="Windows Remote Management 
> (HTTP-In)" new enable=yes action=block
>
> # Delete any existing WinRM listeners
> winrm delete winrm/config/listener?Address=*+Transport=HTTP  2>$Null
> winrm delete winrm/config/listener?Address=*+Transport=HTTPS 2>$Null
>
> # Create a new WinRM listener and configure
> winrm create winrm/config/listener?Address=*+Transport=HTTP
> winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'
> winrm set winrm/config '@{MaxTimeoutms="720"}'
> winrm set winrm/config/service '@{AllowUnencrypted="true"}'
> winrm set winrm/config/service '@{MaxConcurrentOperationsPerUser="12000"}'
> winrm set winrm/config/service/auth '@{Basic="true"}'
> winrm set winrm/config/client/auth '@{Basic="true"}'
>
> # Configure UAC to allow privilege elevation in remote shells
> $Key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
> $Setting = 'LocalAccountTokenFilterPolicy'
> Set-ItemProperty -Path $Key -Name $Setting -Value 1 -Force
>
> # Configure and restart the WinRM Service; Enable the required firewall 
> exception
> Stop-Service -Name WinRM
> Set-Service -Name WinRM -StartupType Automatic
> netsh advfirewall firewall set rule name="Windows Remote Management 
> (HTTP-In)" new action=allow localip=any remoteip=any
> Start-Service -Name WinRM
>
>
>
> Packer template
> {
>"variables": {
>  "client_id": "",
>  "client_secret": "",
>  "tenant_id": "",
>  "subscription_id": "",
>  "object_id": "",
>  "managed_image_resource_group_name": "",
>  "managed_image_name": "",
>  "virtual_network_name": "",
>  "virtual_network_subnet_name": "",
>  "virtual_network_resource_group_name": "",
>  "file_source": "",
>  "packer_ado_pat": ""
>  },
>"builders": [{
>  "type": "azure-arm",
>  
>  "client_id": "{{user `client_id`}}",
>  "client_secret": "{{user `client_secret`}}",
>  "tenant_id": "{{user `tenant_id`}}",
>  "subscription_id": "{{user `subscription_id`}}",
>  "object_id": "{{user `object_id`}}",
>  
>  "managed_image_resource_group_name": "{{user 
> `managed_image_resource_group_name`}}",
>  "managed_image_name": "{{user `managed_image_name`}}",
>  
>  "virtual_network_name": "{{user `virtual_network_name`}}",   
> 
>   "virtual_network_subnet_name": "{{user 
> `virtual_network_subnet_name`}}",   
>   "virtual_network_resource_group_name": "{{user 
> `virtual_network_resource_group_name`}}",
>  
>  "os_type": "Windows",
>  "image_publisher": "MicrosoftWindowsServer",
>  "image_offer": "WindowsServer",
>  "image_sku": "2016-Datacenter",
>  
>  "user_data_file": "{{user `file_source`}}/Bootstrap-Winrm.ps1",
>
>   "communicator": "winrm",
>  "winrm_use_ssl": "true",
>  "winrm_insecure": "true",
>  "winrm_timeout": "5m",
>  "winrm_username": "admin",
>  "winrm_password": "admin12",
>
>  
>  "location": "australiasoutheast",
>  "vm_size": "Standard_A4m_v2"
>}],
>"provisioners": [
>  {
>"type": "powershell",
>"inline": ["mkdir c:\\Packer"]
>  },{
>"type": "file",
>"source": "{{user `file_source`}}",
>"destination": "c:\\Packer"
>  },{
>"type": "powershell",
>"scripts": "{{user `file_source`}}/Bootstrap-winrm.ps1"
>  },{
>  "type": "powershell",
>  "inline": [
>"Add-WindowsFeature Web-Server",
>"if( Test-Path 
> $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml 
> ){ rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}",
>"& 

[packer] Re: How to create a Packer Windows image with winrm enabled ? (azure)

2019-10-16 Thread Jimster
Have you also checked your firewalls are open for the relevant winRM ports 
being used?  Both on the server being provisioned (Windows Firewall) and in 
your corp infrastructure and security group?  (I am AWS but the therory is 
the same)

I am using the following userdata file for WinRM and this is working well:


write-output "Running User Data Script"
write-host "(host) Running User Data Script"

Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction 
Ignore

# Don't set this before Set-ExecutionPolicy as it throws an error
$ErrorActionPreference = "stop"

# Remove HTTP listener
Remove-Item -Path WSMan:\Localhost\listener\listener* -Recurse

$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My 
-DnsName "packer"
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * 
-CertificateThumbPrint $Cert.Thumbprint -Force

#Create Folder for Package Source Files (AMI Install Version)
Write-Host "Doing Temp File Folder Creation"
New-Item -Path "c:\" -name "temp" -itemType "directory" -force

# WinRM
write-output "Setting up WinRM"
write-host "(host) setting up WinRM"

cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm set "winrm/config" '@{MaxTimeoutms="180"}'
cmd.exe /c winrm set "winrm/config/winrs" '@{MaxMemoryPerShellMB="1024"}'
cmd.exe /c winrm set "winrm/config/service" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/client" '@{AllowUnencrypted="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/client/auth" '@{Basic="true"}'
cmd.exe /c winrm set "winrm/config/service/auth" '@{CredSSP="true"}'
cmd.exe /c winrm set "winrm/config/listener?Address=*+Transport=HTTPS" 
"@{Port=`"5986`";Hostname=`"packer`";CertificateThumbprint=`"$($Cert.Thumbprint)`"}"
cmd.exe /c netsh advfirewall firewall set rule group="remote 
administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5986 "Port 5986"
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 2048
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm



This is called from my builder .json files as so:
"builders": [{
"type": "amazon-ebs",
"vpc_id":   "vpc-xxx",
"subnet_id":"subnet-xxx",
"region":   "xxx",
"source_ami":   "xxx",
"ami_name": "my-ami-name-{{timestamp}}",
*"user_data_file":   "./USERDATA2.0.txt",  <=== CALL IT HERE*
"communicator": "winrm",
"winrm_username":   "Administrator",
"instance_type":"t2.large",
"winrm_use_ssl":true,
"winrm_insecure":   true
}],


See how you go.


On Wednesday, 28 August 2019 07:41:40 UTC+1, Sim wrote:
>
> Hi, 
>
> I am currently running into an issue that my Terraform could not connect 
> back to the VM it provisioned in order to connect to Chef server (via chef 
> provisioner) because it could not establish a connection to the VM. I think 
> it might be because the Packer image that I used in Terraform has not been 
> enabled for the winrm. I have looked around on the internet, but still 
> could not find out a good way to enable winrm in the packer. 
> I have tried to call a powershell file in the Packer template. The PS 
> script has a bunch of PS commands that enable winrm. But it didnt work when 
> I ran Packer build. 
>
> What I have tried:
> #bootstrap-winrm.ps1
> # Set administrator password
> net user admin admin12
> wmic useraccount where "name='admin'" set PasswordExpires=FALSE
>
> # First, make sure WinRM can't be connected to
> netsh advfirewall firewall set rule name="Windows Remote Management 
> (HTTP-In)" new enable=yes action=block
>
> # Delete any existing WinRM listeners
> winrm delete winrm/config/listener?Address=*+Transport=HTTP  2>$Null
> winrm delete winrm/config/listener?Address=*+Transport=HTTPS 2>$Null
>
> # Create a new WinRM listener and configure
> winrm create winrm/config/listener?Address=*+Transport=HTTP
> winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="0"}'
> winrm set winrm/config '@{MaxTimeoutms="720"}'
> winrm set winrm/config/service '@{AllowUnencrypted="true"}'
> winrm set winrm/config/service '@{MaxConcurrentOperationsPerUser="12000"}'
> winrm set winrm/config/service/auth '@{Basic="true"}'
> winrm set winrm/config/client/auth '@{Basic="true"}'
>
> # Configure UAC to allow privilege elevation in remote shells
> $Key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
> $Setting = 'LocalAccountTokenFilterPolicy'
> Set-ItemProperty -Path $Key -Name $Setting -Value 1 -Force
>
> # Configure and restart the WinRM Service; Enable the required firewall 
> exception
> Stop-Service -Name WinRM
> Set-Service -Name WinRM -StartupType Automatic
> netsh advfirewall firewall set rule name="Windows Remote Management 
> (HTTP-In)" new action=allow localip=any remoteip=any
> Start-Service -Name WinRM
>
>
>
> Packer template
> {
>

[packer] Passing Tags & Run_tags Blocks in var-file : Is This Possible?

2019-10-16 Thread Jimster
Hi,

Been tasked with cleaning up packer code to remove duplication of explicit 
values in our working  build .json files - and use a few general *var-files* 
that will contain the relevant DEV, TEST and PROD instance types, vpc 
details, disk sizes etc.

One of the builders sections we use are *tags *(and *run_tags*) of the 
format:

"run_tags": {
   "Environment":  "DEV",
   "Application":  "Dave",
   "Tier": "Web App",
   "Function": "Dev Dave Web App",
   "Version":  "1.0",
   "CostCentre":   "0300 3246",
   "BusinessUnit": "AppServices",
   "Project":  "DaveMigration to AWS",
   "Product":  "IIS Server for Dave",
   "SupportEmail": "d...@dave.com",
   "ComplianceDomain": "YES",
   "DataClass":"5",
   "ProvisionedBy":"Packer",
   "ProvisionedWho":   "d...@dave.com",
   "ProjectName":  "Dave",
   "Name": "Dave Dev Web Box"
   },

I'm not sure if or how I can include these arrays in a var-file.  Ideally 
the build file wants to refer to these as some kind of user variable e.g. 
in line with the usual ones:
"builders": [{
   "type": "amazon-ebs",

"region":   "{{ user `DEV_server_region`}}",
   "source_ami":   "{{ user `DEV_server_source_ami`}}",
*"tags": "{{ user `DEV_dave_tags`}}",  <== WHATEVER 
FORMAT THIS SHOULD BE IN FOR A TAG BLOCK (Array?)*
   "instance_type":"{{ user `DEV_server_instance_type`}}",
   "winrm_use_ssl":true,
   "winrm_insecure":   true
   }],

I've tried to capture these tag arrays in the var-file as so (snippet):
...

"PROD_server_user_data_file":   "./USERDATA2.0.txt",

"CA_server_run_tags": [{
   "Environment":  "DEV",
   "Application":  "Dave",
   "Tier": "Web App",
   "Function": "Dev Dave Web App",
   "Version":  "1.0",
   "CostCentre":   "0300 3246",
   "BusinessUnit": "AppServices",
   "Project":  "DaveMigration to AWS",
   "Product":  "IIS Server for Dave",
   "SupportEmail": "d...@dave.com",
   "ComplianceDomain": "YES",
   "DataClass":"5",
   "ProvisionedBy":"Packer",
   "ProvisionedWho":   "d...@dave.com",
   "ProjectName":  "Dave",
   "Name": "Dave Dev Web Box"
}]


But I get:
packer validate -var-file .\dave_vars.json .\build_var_test_Dave.json
invalid value ".\\dave_vars.json" for flag -var-file: Error reading 
variables in '.\dave_vars.json': json: cannot unmarshal array into Go value 
of type string

Can someone please advise on how best to include (if possible) these tags 
and run_tags arrays into the var-file *and* refer to the resulting user 
array variable properly in the builder file?

Thanks,
Jimster

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/8975abcb-e431-4005-8e76-b40f6b048e8f%40googlegroups.com.


[packer] Re: How to create a Packer Windows image with winrm enabled ? (azure)

2019-10-16 Thread Sébastien Barthélémy
Hello,

I've been running successfully packer and terraform with WinRM on AWS with 
this script
https://gitlab.com/sbarthelemy/conan-public-recipes/blob/master/ci/packer/scripts/ec2-winrm.ps1

An important part was to undo the setup at the end in a tear-down step. 
(I'm not sure it applies to you, maybe it matters when certificates are 
used).
You can see the template here
https://gitlab.com/sbarthelemy/conan-public-recipes/blob/master/ci/packer/gitlabrunner-mini-win2016.json

This other script was also useful when debugging:
https://gitlab.com/sbarthelemy/conan-public-recipes/blob/master/ci/packer/scripts/debug-winrm.ps1

Hope it helps!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/735b811d-4307-4b6d-b8c5-7475b077345f%40googlegroups.com.