tl:dr The Ansible provision will not connect to my Windows EC2 instances
This is my packer file:
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "eu-west-2",
"vpc_id": "vpc-071989c63a4a111a2",
"subnet_id": "subnet-04e9835b580b420b4",
"source_ami": "ami-00ab607c2193c70c9",
"instance_type": "t2.micro",
"ami_name": "Windows Core 1809 {{timestamp}}",
"user_data_file": "./user_data.ps1",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_use_ssl": true,
"winrm_insecure": true,
"run_tags": [
{ "windows": "" }
]
}],
"provisioners": [
{
"type": "ansible",
"playbook_file": "../playbooks/windows_image_build/playbook.yml",
"extra_arguments": [
"--extra-vars", "{'environment_name': 'packer',
'hosting_environment': 'aws', 'connection': 'packer'}",
"--skip-tags", "gitchecks",
"--skip-tags", "gather_facts",
"--skip-tags", "slack"
]
}
]
}
The builder runs fine but the Ansible provisioner fails with this error:
==> amazon-ebs: Provisioning with Ansible...
==> amazon-ebs: Executing Ansible: ansible-playbook --extra-vars
packer_build_name=amazon-ebs packer_builder_type=amazon-ebs -i /tmp/packer-
provisioner-ansible213362483 /home/richard/git/ansible/playbooks/
windows_image_build/playbook.yml --private-key /tmp/ansible-key656970276 --
extra-vars environment_name=packer --extra-vars hosting_environment=aws --
extra-vars connection=packer --skip-tags gitchecks --skip-tags gather_facts
--skip-tags slack
amazon-ebs: [WARNING]: Found variable using reserved name: connection
amazon-ebs:
amazon-ebs: PLAY [all]
*********************************************************************
amazon-ebs:
amazon-ebs: TASK [Gathering Facts]
*********************************************************
amazon-ebs: fatal: [default]: UNREACHABLE! => {"changed": false, "msg":
"Authentication
or permission failure. In some cases, you may have been able to
authenticate and did not have permissions on the target directory. Consider
changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\".
Failed command was: ( umask 77 && mkdir -p \"` echo
~/.ansible/tmp/ansible-tmp-1565621734.13375-223774312712604 `\" && echo
ansible-tmp-1565621734.13375-223774312712604=\"` echo
~/.ansible/tmp/ansible-tmp-1565621734.13375-223774312712604 `\" ), exited
with result 1", "unreachable": true}
amazon-ebs: to retry, use: --limit @/home/richard/git/ansible/
playbooks/windows_image_build/playbook.retry
amazon-ebs:
amazon-ebs: PLAY RECAP
*********************************************************************
amazon-ebs: default : ok=0 changed=0
unreachable=1 failed=0
I'm confused because it appears to be referring to the target box, but is
also referring to Linux paths (/tmp). The /tmp directory on the system I'm
running packer from never visibly contains the temporary paths mentioned,
even when stepping through using the -debug option.
If I manually hook it up using the ec2 inventory plugin:
plugin: aws_ec2
regions:
- eu-west-2
filters:
tag:Name: Packer Builder
compose:
ansible_host: private_ip_address
hostnames:
- network-interface.addresses.private-ip-address
and the following group vars:
ansible_connection: winrm
ansible_winrm_transport: ntlm
ansible_winrm_server_cert_validation: ignore
ansible_port: 5986
ansible_winrm_scheme: https
then Ansible will connection start running the playbook. I did try to do a
manual connection use a local-shell provisioner but there doesn't appear to
be any way to retrieve the ip address from Packer.
I can only assume I'm doing something wrong or the provisioner is broken.
Can any one give me some clues here?
--
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/9eb4db18-0ea0-478c-a569-ba4adda97b84%40googlegroups.com.