Hi I’m trying to build Windows 2012r2 ec2 windows AMI that I can provisioned Powershell over winrm but I’m getting SSL exception error as below. Running Ansible playbook ping verified and win command getting the hostname, however, running local command to get the hostname fails.
ssl: HTTPSConnectionPool(host=‘localhost’, port=5986): Max retries exceeded with url: /wsman
xxxx-amzn-win2012r2-sysprep-base: ansible-playbook 2.7.10
xxxx-amzn-win2012r2-sysprep-base: [DEPRECATION WARNING]: ANSIBLE_HOSTS option, The variable is misleading as it
xxxx-amzn-win2012r2-sysprep-base: config file = /home/packer/appcode/tmp/amzn-win2012r2sysp/ansible.cfg
xxxx-amzn-win2012r2-sysprep-base: can be a list of hosts and/or paths to inventory sources , use
xxxx-amzn-win2012r2-sysprep-base: configured module search path = [u’/etc/ansible/library’]
xxxx-amzn-win2012r2-sysprep-base: ANSIBLE_INVENTORY instead. This feature will be removed in version 2.8.
xxxx-amzn-win2012r2-sysprep-base: ansible python module location = /usr/lib/python2.7/site-packages/ansible
xxxx-amzn-win2012r2-sysprep-base: Deprecation warnings can be disabled by setting deprecation_warnings=False in
xxxx-amzn-win2012r2-sysprep-base: executable location = /bin/ansible-playbook
xxxx-amzn-win2012r2-sysprep-base: ansible.cfg.
xxxx-amzn-win2012r2-sysprep-base: python version = 2.7.16 (default, Dec 12 2019, 23:58:22) [GCC 7.3.1 20180712 (Red Hat 7.3.1-6)]
xxxx-amzn-win2012r2-sysprep-base: Using /home/packer/appcode/tmp/amzn-win2012r2sysp/ansible.cfg as config file
xxxx-amzn-win2012r2-sysprep-base: setting up inventory plugins
xxxx-amzn-win2012r2-sysprep-base: Parsed /tmp/packer-provisioner-ansible306731865 inventory source with ini plugin
xxxx-amzn-win2012r2-sysprep-base: Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc
xxxx-amzn-win2012r2-sysprep-base:
xxxx-amzn-win2012r2-sysprep-base: PLAYBOOK: win-playbook-test.yaml ***********************************************
xxxx-amzn-win2012r2-sysprep-base: 1 plays in /home/packer/appcode/tmp/amzn-win2012r2sysp/packer/ansible/win-playbook-test.yaml
xxxx-amzn-win2012r2-sysprep-base:
xxxx-amzn-win2012r2-sysprep-base: PLAY [test out local action] ***************************************************
xxxx-amzn-win2012r2-sysprep-base:
xxxx-amzn-win2012r2-sysprep-base: TASK [Gathering Facts] *********************************************************
xxxx-amzn-win2012r2-sysprep-base: task path: /home/packer/appcode/tmp/amzn-win2012r2sysp/packer/ansible/win-playbook-test.yaml:2
xxxx-amzn-win2012r2-sysprep-base: Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/setup.ps1
xxxx-amzn-win2012r2-sysprep-base: <10.127.51.241> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.127.51.241
xxxx-amzn-win2012r2-sysprep-base: checking if winrm_host 10.127.51.241 is an IPv6 address
xxxx-amzn-win2012r2-sysprep-base: EXEC (via pipeline wrapper)
xxxx-amzn-win2012r2-sysprep-base: ok: [default]
xxxx-amzn-win2012r2-sysprep-base: META: ran handlers
xxxx-amzn-win2012r2-sysprep-base:
xxxx-amzn-win2012r2-sysprep-base: TASK [windows command] *********************************************************
xxxx-amzn-win2012r2-sysprep-base: task path: /home/packer/appcode/tmp/amzn-win2012r2sysp/packer/ansible/win-playbook-test.yaml:5
xxxx-amzn-win2012r2-sysprep-base: Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win_command.ps1
xxxx-amzn-win2012r2-sysprep-base: <10.127.51.241> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO 10.127.51.241
xxxx-amzn-win2012r2-sysprep-base: checking if winrm_host 10.127.51.241 is an IPv6 address
xxxx-amzn-win2012r2-sysprep-base: EXEC (via pipeline wrapper)
xxxx-amzn-win2012r2-sysprep-base: changed: [default] => {
xxxx-amzn-win2012r2-sysprep-base: “changed”: true,
xxxx-amzn-win2012r2-sysprep-base: “cmd”: “hostname”,
xxxx-amzn-win2012r2-sysprep-base: “delta”: “0:00:00.203091”,
xxxx-amzn-win2012r2-sysprep-base: “end”: “2020-01-29 05:40:14.787149”,
xxxx-amzn-win2012r2-sysprep-base: “rc”: 0,
xxxx-amzn-win2012r2-sysprep-base: “start”: “2020-01-29 05:40:14.584057”,
xxxx-amzn-win2012r2-sysprep-base: “stderr”: “”,
xxxx-amzn-win2012r2-sysprep-base: “stderr_lines”: ,
xxxx-amzn-win2012r2-sysprep-base: “stdout”: “WIN-F9EMCU74RLB\r\n”,
xxxx-amzn-win2012r2-sysprep-base: “stdout_lines”: [
xxxx-amzn-win2012r2-sysprep-base: “WIN-F9EMCU74RLB”
xxxx-amzn-win2012r2-sysprep-base: ]
xxxx-amzn-win2012r2-sysprep-base: }
xxxx-amzn-win2012r2-sysprep-base:
xxxx-amzn-win2012r2-sysprep-base: TASK [local command] ***********************************************************
xxxx-amzn-win2012r2-sysprep-base: task path: /home/packer/appcode/tmp/amzn-win2012r2sysp/packer/ansible/win-playbook-test.yaml:8
xxxx-amzn-win2012r2-sysprep-base: Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
xxxx-amzn-win2012r2-sysprep-base: ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5986 TO localhost
xxxx-amzn-win2012r2-sysprep-base: checking if winrm_host localhost is an IPv6 address
xxxx-amzn-win2012r2-sysprep-base: fatal: [default]: UNREACHABLE! => {
xxxx-amzn-win2012r2-sysprep-base: “changed”: false,
xxxx-amzn-win2012r2-sysprep-base: “msg”: “ssl: HTTPSConnectionPool(host=‘localhost’, port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError(‘<urllib3.connection.VerifiedHTTPSConnection object at 0x7f2248dcfad0>: Failed to establish a new connection: [Errno 111] Connection refused’,))”,
xxxx-amzn-win2012r2-sysprep-base: “unreachable”: true
xxxx-amzn-win2012r2-sysprep-base: }
xxxx-amzn-win2012r2-sysprep-base:
xxxx-amzn-win2012r2-sysprep-base: PLAY RECAP *********************************************************************
xxxx-amzn-win2012r2-sysprep-base: default : ok=2 changed=1 unreachable=1 failed=0
xxxx-amzn-win2012r2-sysprep-base:
==> xxxx-amzn-win2012r2-sysprep-base: Provisioning step had errors: Running the cleanup provisioner, if present…
==> xxxx-amzn-win2012r2-sysprep-base: Terminating the source AWS instance…
==> xxxx-amzn-win2012r2-sysprep-base: Cleaning up any extra volumes…
==> xxxx-amzn-win2012r2-sysprep-base: No volumes to clean up, skipping
==> xxxx-amzn-win2012r2-sysprep-base: Deleting temporary security group…
Build ‘xxxx-amzn-win2012r2-sysprep-base’ errored: Error executing Ansible: Non-zero exit status: exit status 4
I’m using winrm==0.2.0 and much appreciated.
John.