Hi,
I'm trying to build windows 2016 ami and provision it with ansible. Can
you advice what I'm doing wrong or what else I should try. I've following
error:
==> amazon-ebs: Provisioning with Powershell...
> ==> amazon-ebs: Provisioning with powershell script:
> /tmp/powershell-provisioner284254996
> amazon-ebs: TaskPath TaskName
> State
> amazon-ebs: -------- --------
> -----
> amazon-ebs: \ Amazon Ec2
> Launch - Instance I... Ready
> ==> amazon-ebs: Provisioning with Ansible...
> ==> amazon-ebs: Executing Ansible: ansible-playbook --extra-vars
> packer_build_name=amazon-ebs packer_builder_type=amazon-ebs -o
> IdentitiesOnly=yes -i /tmp/packer-provisioner-ansible975257195
> /home/build-server_0_playbook.yml -e
> ansible_ssh_private_key_file=/tmp/ansible-key377479228 --connection packer
> -vvv --extra-vars ansible_shell_type=powershell ansible_shell_executable=None
> amazon-ebs: ansible-playbook 2.7.5
> amazon-ebs: config file = /etc/ansible/ansible.cfg
> amazon-ebs: configured module search path =
> ['/home/pr0t/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
> amazon-ebs: ansible python module location =
> /home/repositories/infra-ami/venv/lib/python3.7/site-packages/ansible
> amazon-ebs: executable location = /venv/bin/ansible-playbook
> amazon-ebs: python version = 3.7.3 (default, Mar 26 2019, 21:43:19)
> [GCC 8.2.1 20181127]
> amazon-ebs: Using /etc/ansible/ansible.cfg as config file
> amazon-ebs: /tmp/packer-provisioner-ansible975257195 did not meet
> host_list requirements, check plugin documentation if this is unexpected
> amazon-ebs: /tmp/packer-provisioner-ansible975257195 did not meet script
> requirements, check plugin documentation if this is unexpected
> amazon-ebs: Parsed /tmp/packer-provisioner-ansible975257195 inventory
> source with ini plugin
> amazon-ebs:
> amazon-ebs: PLAYBOOK: build-server_0_playbook.yml
> **************************
> amazon-ebs: 1 plays in build-server_0_playbook.yml
> amazon-ebs:
> amazon-ebs: PLAY [build-server]
> ********************************************
> amazon-ebs:
> amazon-ebs: TASK [Gathering Facts]
> *********************************************************
> amazon-ebs: task path: build-server_0_playbook.yml:3
> amazon-ebs: <127.0.0.1> ESTABLISH SSH CONNECTION FOR USER: pr0t
> amazon-ebs: <127.0.0.1> SSH: EXEC ssh -C -o ControlMaster=auto -o
> ControlPersist=60s -o StrictHostKeyChecking=no -o Port=46089 -o
> 'IdentityFile="/tmp/ansible-key377479228"' -o KbdInteractiveAuthentication=no
> -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
> -o PasswordAuthentication=no -o User=pr0t -o ConnectTimeout=10 -o
> ControlPath=/home/pr0t/.ansible/cp/4a94304e09 127.0.0.1 'PowerShell
> -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -EncodedCommand
> *redacted*'
> ==> amazon-ebs: http response error: 401 - invalid content type
>
> My setup:
packer.json
> "communicator": "winrm",
> "user_data_file":"packer/win.cmd",
> "winrm_username": "Administrator",
> "winrm_timeout": "10m"
> "provisioners": [
> {
> "type": "powershell",
> "inline": [
>
> "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/InitializeInstance.ps1
> -Schedule",
>
> "C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/SysprepInstance.ps1
> -NoShutdown"
> ]
> },
> {
> "type": "ansible",
> "playbook_file": "build-server_0_playbook.yml",
> "extra_arguments": [
> "--connection", "packer",
> "--extra-vars", "ansible_shell_type=powershell
> ansible_shell_executable=None"
> ]
> }
> ],
>
>
win.cmd :
<powershell>
# turn off PowerShell execution policy restrictions
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
# configure WinRM
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}'
winrm set winrm/config/winrs '@{MaxConcurrentUsers="100"}'
winrm set winrm/config/winrs '@{MaxProcessesPerShell="0"}'
winrm set winrm/config/winrs '@{MaxShellsPerUser="0"}'
winrm set winrm/config '@{MaxTimeoutms="7200000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/service/auth '@{CredSSP="true"}'
winrm set winrm/config/client '@{TrustedHosts="*"}'
# open port 5985 in the internal Windows firewall to allow WinRM communication
netsh advfirewall firewall add rule name="WinRM 5985" protocol=TCP dir=in
localport=5985 action=allow
net stop winrm
sc config winrm start=auto
net start winrm </powershell>
Ansible plugin:
https://github.com/hashicorp/packer/blob/v1.4.0/examples/ansible/connection-plugin/2.6.x/packer.py
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/fdcc5449-ef7d-4c6d-9c50-9c36b2aba2f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.