Packer + Ansible -> Windows

1,444 views
Skip to first unread message

SurferL

unread,
Nov 23, 2017, 11:37:16 AM11/23/17
to Packer
I don't suppose someone can share their successful configuration for getting Packer with Ansible provisioner to Windows to work?

I'm having major issues with the SSH connection cutting out during the Ansible provision stage.

My current set up is something as follows:

MacOSX running Packer -> Windows 7 machine (with winrm configured)

Packer --version: 1.1.2
Ansible --version: 2.4.1.0

Packer template provisioner section:

"provisioners": [
{
"type": "ansible",
"user": "{{ user `username` }}",
"playbook_file": "./ansible/site.yml",
"groups": [
"{{ user `ansible_group` }}"
],
"ansible_env_vars": [
"ANSIBLE_CONFIG=../../../ansible/ansible.cfg",
"ANSIBLE_HOST_KEY_CHECKING=False",
"ANSIBLE_SSH_ARGS='-o ForwardAgent=yes'"
],
"extra_arguments": [
"-vvvv",
"--extra-vars", "ansible_shell_type=powershell ansible_shell_executable=None ansible_user={{ user `username` }} ansible_password={{ user `password` }} ansible_become_pass={{ user `password` }}",
"--connection", "packer"
]
}
]

connection_plugins/packer.py

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible.plugins.connection.ssh import Connection as SSHConnection

class Connection(SSHConnection):
''' ssh based connections for powershell via packer'''

transport = 'packer'
has_pipelining = True
become_methods = []
allow_executable = False
module_implementation_preferences = ('.ps1', '')

def __init__(self, *args, **kwargs):
super(Connection, self).__init__(*args, **kwargs)

 
ansible.cfg

[defaults]
roles_path=./ansible/roles/external:./ansible/roles/internal
host_key_checking = False
force_color = 1
retry_files_enabled = False

The errors I get vary:

channel 0: request exec confirm 1\r\ndebug2: callback done\r\ndebug2: channel 0: open confirm rwindow 2097152 rmax 32768\r\ndebug2: channel_input_status_confirm: type 99 id 0\r\ndebug2: PTY allocation request accepted on channel 0\r\ndebug2: channel_input_status_confirm: type 99 id 0\r\ndebug2: exec request accepted on channel 0\r\ndebug2: channel 0: rcvd ext data 840\r\n#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="2"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>debug2: channel 0: written 840 to efd 7\r\ndebug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r\ndebug2: channel 0: rcvd close\r\ndebug2: channel 0: output open -> drain\r\ndebug2: channel 0: close_read\r\ndebug2: channel 0: input open -> closed\r\ndebug3: channel 0: will not send data after close\r\ndebug2: channel 0: obuf empty\r\ndebug2: channel 0: close_write\r\ndebug2: channel 0: output drain -> closed\r\ndebug2: channel 0: almost dead\r\ndebug2: channel 0: gc: notify user\r\ndebug2: channel 0: gc: user detached\r\ndebug2: channel 0: send close\r\ndebug2: channel 0: is dead\r\ndebug2: channel 0: garbage collecting\r\ndebug1: channel 0: free: client-session, nchannels 1\r\ndebug3: channel 0: status: The following connections are open:\r\n #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)\r\n\r\ndebug1: fd 1 clearing O_NONBLOCK\r\ndebug1: fd 2 clearing O_NONBLOCK\r\nConnection to 127.0.0.1 closed.\r\nTransferred: sent 4740, received 2600 bytes, in 1.9 seconds\r\nBytes per second: sent 2510.8, received 1377.2\r\ndebug1: Exit status 1\r\n')
2017/11/23 16:26:04 ui: vsphere: The full traceback is:
2017/11/23 16:26:04 ui: vsphere: At line:4 char:3
2017/11/23 16:26:04 ui: vsphere: + & 'win_get_url.ps1'
2017/11/23 16:26:04 ui: vsphere: + ~~~~~~~~~~~~~~~~~
2017/11/23 16:26:04 ui: vsphere: failed: [default] (item={u'url': u'redacted', u'kb': u'KB3035131', u'idx': 2}) => {
2017/11/23 16:26:04 ui: vsphere: "changed": false,
2017/11/23 16:26:04 ui: vsphere: "failed": true,
2017/11/23 16:26:04 ui: vsphere: "item": {
2017/11/23 16:26:04 ui: vsphere: "idx": 2,
2017/11/23 16:26:04 ui: vsphere: "kb": "KB3035131",
2017/11/23 16:26:04 ui: vsphere: "url": "redacted"
2017/11/23 16:26:04 ui: vsphere: },
2017/11/23 16:26:04 ui: vsphere: "msg": "The term 'win_get_url.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
2017/11/23 16:26:04 ui: vsphere: }
2017/11/23 16:26:04 ui: vsphere:
2017/11/23 16:26:04 ui: vsphere: PLAY RECAP *********************************************************************
2017/11/23 16:26:04 ui: vsphere: default : ok=8 changed=3 unreachable=0 failed=1
2017/11/23 16:26:04 ui: vsphere:
2017/11/23 16:26:04 ui: vsphere: "changed": false,
2017/11/23 16:26:04 ui: vsphere: "failed": true,
2017/11/23 16:26:04 ui: vsphere: "item": {
2017/11/23 16:26:04 ui: vsphere: "idx": 2,
2017/11/23 16:26:04 ui: vsphere: "kb": "KB3035131",
2017/11/23 16:26:04 ui: vsphere: "url": "redacted"
2017/11/23 16:26:04 ui: vsphere: },
2017/11/23 16:26:04 ui: vsphere: "msg": "The term 'win_get_url.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
2017/11/23 16:26:04 ui: vsphere: }
2017/11/23 16:26:04 ui: vsphere:
2017/11/23 16:26:04 ui: vsphere: PLAY RECAP *********************************************************************
2017/11/23 16:26:04 ui: vsphere: default : ok=8 changed=3 unreachable=0 failed=1
2017/11/23 16:26:04 ui: vsphere:
vsphere: <127.0.0.1> (1, '{"exception":"At line:4 char:3\\r\\n+ \\u0026 \\u0027win_get_url.ps1\\u0027\\r\\n+ ~~~~~~~~~~~~~~~~~","msg":"The term \\u0027win_get_url.ps1\\u0027 is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.","failed":true}\r\n', 'OpenSSH_6.9p1, LibreSSL 2.1.8\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: ssh_connect: needpriv 0\r\ndebug1: Connecting to 127.0.0.1 [127.0.0.1] port 54271.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: fd 3 clearing O_NONBLOCK\r\ndebug1: Connection established.\r\ndebug3: timeout: 10000 ms remain after connect\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /private/var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/ansible-key132482501 type -1\r\ndebug1: key_load_public: No such file or directory\r\ndebug1: identity file /private/var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/ansible-key132482501-cert type -1\r\ndebug1: Enabling compatibility mode for protocol 2.0\r\ndebug1: Local version string SSH-2.0-OpenSSH_6.9\r\ndebug1: Remote protocol version 2.0, remote software version Go\r\ndebug1: no match: Go\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: Authenticating to 127.0.0.1:54271 as \'username\'\r\ndebug3: put_host_port: [127.0.0.1]:54271\r\ndebug3: hostkeys_foreach: reading file "/Users/username/.ssh/known_hosts"\r\ndebug3: record_hostkey: found key type RSA in file /Users/username/.ssh/known_hosts:37\r\ndebug3: load_hostkeys: loaded 1 keys from [127.0.0.1]:54271\r\ndebug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-...@openssh.com,ssh-rsa-...@openssh.com,ssh-rsa\r\ndebug1: SSH2_MSG_KEXINIT sent\r\ndebug1: SSH2_MSG_KEXINIT received\r\ndebug2: kex_parse_kexinit: curve255...@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1\r\ndebug2: kex_parse_kexinit: ssh-rsa-...@openssh.com,ssh-rsa-...@openssh.com,ssh-rsa,ecdsa-sha2-nis...@openssh.com,ecdsa-sha2-nis...@openssh.com,ecdsa-sha2-nis...@openssh.com,ssh-ed2551...@openssh.com,ssh-dss-...@openssh.com,ssh-dss-...@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss\r\ndebug2: kex_parse_kexinit: chacha20...@openssh.com,aes128-ctr,

to something like:

vsphere: <127.0.0.1> (148, '{"choco_error_cmd":"choco.exe install -r --no-progress -y nsis --timeout 2700 --failonunfound --allow-empty-checksums","stdout":"Installing the following packages:\\r\\nnsis\\r\\nBy installing you accept licenses for the packages.\\r\\n\\r\\nnsis.install v3.02.0.20160720 [Approved]\\r\\nnsis.install package files install completed. Performing other installation steps.\\r\\nDownloading nsis.install \\r\\n from \\u0027https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download\\u0027\\r\\nERROR: The remote file either doesn\\u0027t exist, is unauthorized, or is forbidden for url \\u0027https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download\\u0027. Exception calling \\"GetResponse\\" with \\"0\\" argument(s): \\"The operation has timed out\\" \\r\\nThis package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn.\\r\\nThe install of nsis.install was NOT successful.\\r\\nError while running \\u0027C:\\\\ProgramData\\\\chocolatey\\\\lib\\\\nsis.install\\\\tools\\\\chocolateyInstall.ps1\\u0027.\\r\\n See log for details.\\r\\n\\r\\nnsis v3.02.0.20160720 [Approved]\\r\\nnsis package files install completed. Performing other installation steps.\\r\\n The install of nsis was successful.\\r\\n Software install location not explicitly set, could be in package or \\r\\n default install location if installer.\\r\\n\\r\\nChocolatey installed 1/2 packages. 1 packages failed.\\r\\n See the log for details (C:\\\\ProgramData\\\\chocolatey\\\\logs\\\\chocolatey.log).\\r\\n\\r\\nFailures\\r\\n - nsis.install (exited 404) - Error while running \\u0027C:\\\\ProgramData\\\\chocolatey\\\\lib\\\\nsis.install\\\\tools\\\\chocolateyInstall.ps1\\u0027.\\r\\n See log for details.\\r\\n","command":"choco.exe install -r --no-progress -y nsis --timeout 2700 --failonunfound --allow-empty-checksums","changed":false,"rc":404,"choco_error_log":["Installing the following packages:","nsis","By installing you accept licenses for the packages.","","nsis.install v3.02.0.20160720 [Approved]","nsis.install package files install completed. Performing other installation steps.","Downloading nsis.install "," from \\u0027https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download\\u0027","ERROR: The remote file either doesn\\u0027t exist, is unauthorized, or is forbidden for url \\u0027https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download\\u0027. Exception calling \\"GetResponse\\" with \\"0\\" argument(s): \\"The operation has timed out\\" ","This package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn.","The install of nsis.install was NOT successful.","Error while running \\u0027C:\\\\ProgramData\\\\chocolatey\\\\lib\\\\nsis.install\\\\tools\\\\chocolateyInstall.ps1\\u0027."," See log for details.","","nsis v3.02.0.20160720 [Approved]","nsis package files install completed. Performing other installation steps."," The install of nsis was successful."," Software install location not explicitly set, could be in package or "," default install location if installer.","","Chocolatey installed 1/2 packages. 1 packages failed."," See the log for details (C:\\\\ProgramData\\\\chocolatey\\\\logs\\\\chocolatey.log).","","Failures"," - nsis.install (exited 404) - Error while running \\u0027C:\\\\ProgramData\\\\chocolatey\\\\lib\\\\nsis.install\\\\tools\\\\chocolateyInstall.ps1\\u0027."," See log for details."],"failed":true,"msg":"Error installing package \\u0027nsis\\u0027"}\r\n', '#< CLIXML\r\n\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>Shared connection to 127.0.0.1 closed.\r\n')
vsphere: failed: [default] (item={u'package_name': u'nsis'}) => {
vsphere: "changed": false,
vsphere: "choco_error_cmd": "choco.exe install -r --no-progress -y nsis --timeout 2700 --failonunfound --allow-empty-checksums",
vsphere: "choco_error_log": [
vsphere: "Installing the following packages:",
vsphere: "nsis",
vsphere: "By installing you accept licenses for the packages.",
vsphere: "",
vsphere: "nsis.install v3.02.0.20160720 [Approved]",
vsphere: "nsis.install package files install completed. Performing other installation steps.",
vsphere: "Downloading nsis.install ",
vsphere: "ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download'. Exception calling \"GetResponse\" with \"0\" argument(s): \"The operation has timed out\" ",
vsphere: "This package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn.",
vsphere: "The install of nsis.install was NOT successful.",
vsphere: "Error while running 'C:\\ProgramData\\chocolatey\\lib\\nsis.install\\tools\\chocolateyInstall.ps1'.",
vsphere: " See log for details.",
vsphere: "",
vsphere: "nsis v3.02.0.20160720 [Approved]",
vsphere: "nsis package files install completed. Performing other installation steps.",
vsphere: " The install of nsis was successful.",
vsphere: " Software install location not explicitly set, could be in package or ",
vsphere: " default install location if installer.",
vsphere: "",
vsphere: "Chocolatey installed 1/2 packages. 1 packages failed.",
vsphere: " See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log).",
vsphere: "",
vsphere: "Failures",
vsphere: " - nsis.install (exited 404) - Error while running 'C:\\ProgramData\\chocolatey\\lib\\nsis.install\\tools\\chocolateyInstall.ps1'.",
vsphere: " See log for details."
vsphere: ],
vsphere: "command": "choco.exe install -r --no-progress -y nsis --timeout 2700 --failonunfound --allow-empty-checksums",
vsphere: "failed": true,
vsphere: "item": {
vsphere: "package_name": "nsis"
vsphere: },
vsphere: "msg": "Error installing package 'nsis'",
vsphere: "rc": 404,
vsphere: "stdout": "Installing the following packages:\r\nnsis\r\nBy installing you accept licenses for the packages.\r\n\r\nnsis.install v3.02.0.20160720 [Approved]\r\nnsis.install package files install completed. Performing other installation steps.\r\nDownloading nsis.install \r\n from 'https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download'\r\nERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download'. Exception calling \"GetResponse\" with \"0\" argument(s): \"The operation has timed out\" \r\nThis package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn.\r\nThe install of nsis.install was NOT successful.\r\nError while running 'C:\\ProgramData\\chocolatey\\lib\\nsis.install\\tools\\chocolateyInstall.ps1'.\r\n See log for details.\r\n\r\nnsis v3.02.0.20160720 [Approved]\r\nnsis package files install completed. Performing other installation steps.\r\n The install of nsis was successful.\r\n Software install location not explicitly set, could be in package or \r\n default install location if installer.\r\n\r\nChocolatey installed 1/2 packages. 1 packages failed.\r\n See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log).\r\n\r\nFailures\r\n - nsis.install (exited 404) - Error while running 'C:\\ProgramData\\chocolatey\\lib\\nsis.install\\tools\\chocolateyInstall.ps1'.\r\n See log for details.\r\n",
vsphere: "stdout_lines": [
vsphere: "Installing the following packages:",
vsphere: "nsis",
vsphere: "By installing you accept licenses for the packages.",
vsphere: "",
vsphere: "nsis.install v3.02.0.20160720 [Approved]",
vsphere: "nsis.install package files install completed. Performing other installation steps.",
vsphere: "Downloading nsis.install ",
vsphere: "ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://sourceforge.net/projects/nsis/files/NSIS%203%20Pre-release/3.0rc2/nsis-3.0rc2-setup.exe/download'. Exception calling \"GetResponse\" with \"0\" argument(s): \"The operation has timed out\" ",
vsphere: "This package is likely not broken for licensed users - see https://chocolatey.org/docs/features-private-cdn.",
vsphere: "The install of nsis.install was NOT successful.",
vsphere: "Error while running 'C:\\ProgramData\\chocolatey\\lib\\nsis.install\\tools\\chocolateyInstall.ps1'.",
vsphere: " See log for details.",
vsphere: "",
vsphere: "nsis v3.02.0.20160720 [Approved]",
vsphere: "nsis package files install completed. Performing other installation steps.",
vsphere: " The install of nsis was successful.",
vsphere: " Software install location not explicitly set, could be in package or ",
vsphere: " default install location if installer.",
vsphere: "",
vsphere: "Chocolatey installed 1/2 packages. 1 packages failed.",
vsphere: " See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log).",
vsphere: "",
vsphere: "Failures",
vsphere: " - nsis.install (exited 404) - Error while running 'C:\\ProgramData\\chocolatey\\lib\\nsis.install\\tools\\chocolateyInstall.ps1'.",
vsphere: " See log for details."
vsphere: ]
vsphere: }
vsphere: Using module file /Users/username/gitlabs/inf_orchestration_v2/venv_vsphere_pyvmomi/lib/python2.7/site-packages/ansible/modules/windows/win_chocolatey.ps1
vsphere: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: username
vsphere: <127.0.0.1> SSH: EXEC sshpass -d55 ssh -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=30m -o StrictHostKeyChecking=no -o Port=53820 -o 'IdentityFile="/private/var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/ansible-key448416108"' -o User= username -o ConnectTimeout=10 -o ControlPath=/Users/username/.ansible/cp/8a9b06d76f 127.0.0.1 'PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgAoAE4AZQB3AC0ASQB0AGUAbQAgAC0AVAB5AHAAZQAgAEQAaQByAGUAYwB0AG8AcgB5ACAALQBQAGEAdABoACAAJABlAG4AdgA6AHQAZQBtAHAAIAAtAE4AYQBtAGUAIAAiAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANQAxADEANAA1ADIANAA2ADAALgAzADYALQAyADEAMQAzADgAMQAwADEAOAAxADkANAAxADQANgAiACkALgBGAHUAbABsAE4AYQBtAGUAIAB8ACAAVwByAGkAdABlAC0ASABvAHMAdAAgAC0AUwBlAHAAYQByAGEAdABvAHIAIAAnACcAOwAKAEkAZgAgACgALQBuAG8AdAAgACQAPwApACAAewAgAEkAZgAgACgARwBlAHQALQBWAGEAcgBpAGEAYgBsAGUAIABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQAgAC0ARQByAHIAbwByAEEAYwB0AGkAbwBuACAAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQApACAAewAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFACAAfQAgAEUAbABzAGUAIAB7ACAAZQB4AGkAdAAgADEAIAB9ACAAfQA='
vsphere: <127.0.0.1> (0, 'C:\\Users\\username\\AppData\\Local\\Temp\\ansible-tmp-1511452460.36-211381018194146\n', '#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">2</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="2"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="information" RefId="3"><TN RefId="1"><T>System.Management.Automation.InformationRecord</T><T>System.Object</T></TN><ToString>C:\\Users\\username\\AppData\\Local\\Temp\\ansible-tmp-1511452460.36-211381018194146</ToString><Props><Obj N="MessageData" RefId="4"><TN RefId="2"><T>System.Management.Automation.HostInformationMessage</T><T>System.Object</T></TN><ToString>C:\\Users\\username\\AppData\\Local\\Temp\\ansible-tmp-1511452460.36-211381018194146</ToString><Props><S N="Message">C:\\Users\\username\\AppData\\Local\\Temp\\ansible-tmp-1511452460.36-211381018194146</S><B N="NoNewLine">false</B><S N="ForegroundColor">Gray</S><S N="BackgroundColor">Black</S></Props></Obj><S N="Source">C:\\ProgramData\\Boxstarter\\Boxstarter.Chocolatey\\Chocolatey.ps1</S><DT N="TimeGenerated">2017-11-23T15:54:21.3071481+00:00</DT><Obj N="Tags" RefId="5"><TN RefId="3"><T>System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]</T><T>System.Object</T></TN><LST><S>PSHOST</S></LST></Obj><S N="User">win_base\\username</S><S N="Computer">win_base</S><U32 N="ProcessId">3552</U32><U32 N="NativeThreadId">1180</U32><U32 N="ManagedThreadId">7</U32></Props></Obj></Objs>')
 
or something like:

vsphere: TASK [build-machine-SDK : win | Make working directory for zip archives] *******
vsphere: An exception occurred during task execution. To see the full traceback, use -vvv. The error was: + ~~~~~~~~~~~~~~
vsphere: fatal: [default]: FAILED! => {"changed": false, "failed": true, "msg": "The term 'win_file.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."} 

or:

vsphere: Using module file /Users/gitlabs/inf_orchestration_v2/venv_vsphere_pyvmomi/lib/python2.7/site-packages/ansible/modules/windows/win_chocolatey.ps1
    vsphere: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: username
    vsphere: <127.0.0.1> SSH: EXEC sshpass -d57 ssh -o ForwardAgent=yes -o StrictHostKeyChecking=no -o Port=54753 -o 'IdentityFile="/private/var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/ansible-key014387674"' -o User=username -o ConnectTimeout=10 127.0.0.1 'PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgAoAE4AZQB3AC0ASQB0AGUAbQAgAC0AVAB5AHAAZQAgAEQAaQByAGUAYwB0AG8AcgB5ACAALQBQAGEAdABoACAAJABlAG4AdgA6AHQAZQBtAHAAIAAtAE4AYQBtAGUAIAAiAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANQAxADEAMwA2ADUAOQA3ADMALgAxADIALQAxADIAMwA1ADkANwAxADgANAAxADMANAAxADQAMQAiACkALgBGAHUAbABsAE4AYQBtAGUAIAB8ACAAVwByAGkAdABlAC0ASABvAHMAdAAgAC0AUwBlAHAAYQByAGEAdABvAHIAIAAnACcAOwAKAEkAZgAgACgALQBuAG8AdAAgACQAPwApACAAewAgAEkAZgAgACgARwBlAHQALQBWAGEAcgBpAGEAYgBsAGUAIABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQAgAC0ARQByAHIAbwByAEEAYwB0AGkAbwBuACAAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQApACAAewAgAGUAeABpAHQAIAAkAEwAQQBTAFQARQBYAEkAVABDAE8ARABFACAAfQAgAEUAbABzAGUAIAB7ACAAZQB4AGkAdAAgADEAIAB9ACAAfQA='
    vsphere: <127.0.0.1> (0, '', '')
    vsphere: <127.0.0.1> PUT /var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/tmp0JSsUE TO 'win_chocolatey.ps1'
    vsphere: <127.0.0.1> SSH: EXEC sshpass -d57 scp -o ForwardAgent=yes -o StrictHostKeyChecking=no -o Port=54753 -o 'IdentityFile="/private/var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/ansible-key014387674"' -o User=username -o ConnectTimeout=10 /var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/tmp0JSsUE '[127.0.0.1]:'"'"''"'"'"'"'"'"'"'"'win_chocolatey.ps1'"'"'"'"'"'"'"'"''"'"''
    vsphere: <127.0.0.1> (0, '', '')
    vsphere: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: username
    vsphere: <127.0.0.1> SSH: EXEC sshpass -d57 ssh -o ForwardAgent=yes -o StrictHostKeyChecking=no -o Port=54753 -o 'IdentityFile="/private/var/folders/c7/8kvczj9j6m5db7jfh2cfmzsh0000gn/T/ansible-key014387674"' -o User=username -o ConnectTimeout=10 -tt 127.0.0.1 'PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand UwBlAHQALQBTAHQAcgBpAGMAdABNAG8AZABlACAALQBWAGUAcgBzAGkAbwBuACAATABhAHQAZQBzAHQACgBUAHIAeQAKAHsACgAmACAAJwB3AGkAbgBfAGMAaABvAGMAbwBsAGEAdABlAHkALgBwAHMAMQAnAAoAfQAKAEMAYQB0AGMAaAAKAHsACgAkAF8AbwBiAGoAIAA9ACAAQAB7ACAAZgBhAGkAbABlAGQAIAA9ACAAJAB0AHIAdQBlACAAfQAKAEkAZgAgACgAJABfAC4ARQB4AGMAZQBwAHQAaQBvAG4ALgBHAGUAdABUAHkAcABlACkACgB7AAoAJABfAG8AYgBqAC4AQQBkAGQAKAAnAG0AcwBnACcALAAgACQAXwAuAEUAeABjAGUAcAB0AGkAbwBuAC4ATQBlAHMAcwBhAGcAZQApAAoAfQAKAEUAbABzAGUACgB7AAoAJABfAG8AYgBqAC4AQQBkAGQAKAAnAG0AcwBnACcALAAgACQAXwAuAFQAbwBTAHQAcgBpAG4AZwAoACkAKQAKAH0ACgBJAGYAIAAoACQAXwAuAEkAbgB2AG8AYwBhAHQAaQBvAG4ASQBuAGYAbwAuAFAAbwBzAGkAdABpAG8AbgBNAGUAcwBzAGEAZwBlACkACgB7AAoAJABfAG8AYgBqAC4AQQBkAGQAKAAnAGUAeABjAGUAcAB0AGkAbwBuACcALAAgACQAXwAuAEkAbgB2AG8AYwBhAHQAaQBvAG4ASQBuAGYAbwAuAFAAbwBzAGkAdABpAG8AbgBNAGUAcwBzAGEAZwBlACkACgB9AAoARQBsAHMAZQBJAGYAIAAoACQAXwAuAFMAYwByAGkAcAB0AFMAdABhAGMAawBUAHIAYQBjAGUAKQAKAHsACgAkAF8AbwBiAGoALgBBAGQAZAAoACcAZQB4AGMAZQBwAHQAaQBvAG4AJwAsACAAJABfAC4AUwBjAHIAaQBwAHQAUwB0AGEAYwBrAFQAcgBhAGMAZQApAAoAfQAKAFQAcgB5AAoAewAKACQAXwBvAGIAagAuAEEAZABkACgAJwBlAHIAcgBvAHIAXwByAGUAYwBvAHIAZAAnACwAIAAoACQAXwAgAHwAIABDAG8AbgB2AGUAcgB0AFQAbwAtAEoAcwBvAG4AIAB8ACAAQwBvAG4AdgBlAHIAdABGAHIAbwBtAC0ASgBzAG8AbgApACkACgB9AAoAQwBhAHQAYwBoAAoAewAKAH0ACgBFAGMAaABvACAAJABfAG8AYgBqACAAfAAgAEMAbwBuAHYAZQByAHQAVABvAC0ASgBzAG8AbgAgAC0AQwBvAG0AcAByAGUAcwBzACAALQBEAGUAcAB0AGgAIAA5ADkACgBFAHgAaQB0ACAAMQAKAH0A'
    vsphere: <127.0.0.1> (1, '{"exception":"At line:4 char:3\\r\\n+ \\u0026 \\u0027win_chocolatey.ps1\\u0027\\r\\n+   ~~~~~~~~~~~~~~~~~~~~","msg":"The term \\u0027win_chocolatey.ps1\\u0027 is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.","failed":true}\r\n', '#< CLIXML\r\n<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><Obj S="progress" RefId="0"><TN RefId="0"><T>System.Management.Automation.PSCustomObject</T><T>System.Object</T></TN><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="1"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj><Obj S="progress" RefId="2"><TNRef RefId="0" /><MS><I64 N="SourceId">1</I64><PR N="Record"><AV>Preparing modules for first use.</AV><AI>0</AI><Nil /><PI>-1</PI><PC>-1</PC><T>Completed</T><SR>-1</SR><SD> </SD></PR></MS></Obj></Objs>Connection to 127.0.0.1 closed.\r\n')
    vsphere: The full traceback is:
    vsphere: At line:4 char:3

    vsphere: + & 'win_chocolatey.ps1'

    vsphere: +   ~~~~~~~~~~~~~~~~~~~~
    vsphere: failed: [default] (item={u'package_name': u'git'}) => {
    vsphere:     "changed": false, 
    vsphere:     "failed": true, 
    vsphere:     "item": {
    vsphere:         "package_name": "git"
    vsphere:     }, 
    vsphere:     "msg": "The term 'win_chocolatey.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."
    vsphere: }

 Am I missing some kind of configuration to keep the SSH connection between Packer and Ansible going?

I'm out of ideas of how to debug this and what I should be changing - any assistance would be very much appreciated! 

Thanks :) 

SurferL

unread,
Nov 23, 2017, 11:57:51 AM11/23/17
to Packer
Another point to add, is that it pretty much always fails on long playbooks / roles (with multiple installations via win_chocolatey for example), but works fine with a playbook with fewer than 10 tasks...

Rickard von Essen

unread,
Nov 23, 2017, 12:19:26 PM11/23/17
to packe...@googlegroups.com

On Nov 23, 2017 17:57, "SurferL" <lawrenc...@gmail.com> wrote:
Another point to add, is that it pretty much always fails on long playbooks / roles (with multiple installations via win_chocolatey for example), but works fine with a playbook with fewer than 10 tasks...

--
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/80b8478c-bd13-40a4-9e02-82503df0fef6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

SurferL

unread,
Nov 23, 2017, 12:23:44 PM11/23/17
to Packer
Thanks Rickard! I'll have a look and try see what the differences are to hopefully get mine working :) 


On Thursday, 23 November 2017 17:19:26 UTC, Rickard von Essen wrote:
On Nov 23, 2017 17:57, "SurferL" <lawrenc...@gmail.com> wrote:
Another point to add, is that it pretty much always fails on long playbooks / roles (with multiple installations via win_chocolatey for example), but works fine with a playbook with fewer than 10 tasks...

--
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.

Jordan Borean

unread,
Nov 23, 2017, 5:45:38 PM11/23/17
to Packer
Personally I would avoid using the Packer SSH Windows connector as I've seen a few cases where it has been broken in subsequent Ansible releases. Using the default winrm connector guarantees you are running on a supported/tested connection plugin and it shouldn't break on a release. Unfortunately this means you will have to run the Ansible playbook using the shell-local plugin and not through the ansible plugin as Packer doesn't seem to support this configuration yet. I've been able to use the latest version of Ansible to build Windows images from the evaluation ISO and get it working for Ansible, if you are interested in this I've created a blog post that goes into more details here http://www.bloggingforlogging.com/2017/11/23/using-packer-to-create-windows-images/.

Good luck with whatever route you choose to go with.
Reply all
Reply to author
Forward
0 new messages