I’m quite new to packer, so hopefully this is an easy question and down to my lack of knowledge?
I’m trying to create a Windows AMI in AWS and I’m having problems with my provisioners. If I connect to my playbook using:-
provisioner "ansible" {
playbook_file = "../test/ansible/playbook.yml"
user = "Administrator"
extra_arguments = local.ansible_args
timeout = "90m"
}
The local.ansible_args is:-
ansible_args = [
"-e",
"ansible_winrm_server_cert_validation=ignore"
]
I get a an unreachable error:-
build.amazon-ebs.build: WinRM connected.
==> build.amazon-ebs.build: Connected to WinRM!
==> build.amazon-ebs.build: Setting a 1h30m0s timeout for the next provisioner...
==> build.amazon-ebs.build: Provisioning with Ansible...
build.amazon-ebs.build: Setting up proxy adapter for Ansible....
==> build.amazon-ebs.build: Executing Ansible: ansible-playbook -e packer_build_name="build" -e packer_builder_type=amazon-ebs -e ansible_winrm_server_cert_validation=ignore -e ansible_ssh_private_key_file=/tmp/ansible-key912192350 -i /tmp/packer-provisioner-ansible3161160387 /home/ec2-user/environment/Clones/HLR/test/ansible/playbook.yml
build.amazon-ebs.build: [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
build.amazon-ebs.build: controller starting with Ansible 2.12. Current version: 3.6.12 (default, May 18
build.amazon-ebs.build: 2021, 22:47:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]. This feature will be
build.amazon-ebs.build: removed from ansible-core in version 2.12. Deprecation warnings can be disabled
build.amazon-ebs.build: by setting deprecation_warnings=False in ansible.cfg.
build.amazon-ebs.build:
build.amazon-ebs.build: PLAY [AWS] *********************************************************************
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [Gathering Facts] *********************************************************
build.amazon-ebs.build: fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to create temporary directory.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\", for more error information use -vvv. Failed command was: ( umask 77 && mkdir -p \"` echo ~/.ansible/tmp `\"&& mkdir \"` echo ~/.ansible/tmp/ansible-tmp-1649328941.6781094-4573-25582342158625 `\" && echo ansible-tmp-1649328941.6781094-4573-25582342158625=\"` echo ~/.ansible/tmp/ansible-tmp-1649328941.6781094-4573-25582342158625 `\" ), exited with result 1", "unreachable": true}
build.amazon-ebs.build:
build.amazon-ebs.build: PLAY RECAP *********************************************************************
build.amazon-ebs.build: default : ok=0 changed=0 unreachable=1 failed=0 skipped=0 rescued=0 ignored=0
build.amazon-ebs.build:
If I add use_proxy = false into the provisioner it then connects but times out when trying to access the internet, in this example I’m trying to download the AWS CLI .msi file, but it doesn’t matter what you are trying to do over the net.
==> build.amazon-ebs.build: Connected to WinRM!
==> build.amazon-ebs.build: Setting a 1h30m0s timeout for the next provisioner...
==> build.amazon-ebs.build: Provisioning with Ansible...
build.amazon-ebs.build: Not using Proxy adapter for Ansible run:
build.amazon-ebs.build: Using WinRM Password from Packer communicator...
==> build.amazon-ebs.build: Executing Ansible: ansible-playbook -e packer_build_name="build" -e packer_builder_type=amazon-ebs -e ansible_winrm_server_cert_validation=ignore -e ansible_password=***** -i /tmp/packer-provisioner-ansible2926324853 /home/ec2-user/environment/Clones/HLR/pcs-aws-0500-image-hardening/ansible/playbook.yml
build.amazon-ebs.build: [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
build.amazon-ebs.build: controller starting with Ansible 2.12. Current version: 3.6.12 (default, May 18
build.amazon-ebs.build: 2021, 22:47:55) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]. This feature will be
build.amazon-ebs.build: removed from ansible-core in version 2.12. Deprecation warnings can be disabled
build.amazon-ebs.build: by setting deprecation_warnings=False in ansible.cfg.
build.amazon-ebs.build:
build.amazon-ebs.build: PLAY [AWS] *********************************************************************
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [Gathering Facts] *********************************************************
build.amazon-ebs.build: ok: [default]
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : install needed packages] *******************************************
build.amazon-ebs.build: skipping: [default] => (item=unzip)
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : create tmp dir] ****************************************************
build.amazon-ebs.build: skipping: [default]
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : download AWS CLI] **************************************************
build.amazon-ebs.build: skipping: [default]
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : install AWS CLI] ***************************************************
build.amazon-ebs.build: skipping: [default]
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : Test installed] ****************************************************
build.amazon-ebs.build: skipping: [default]
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : cleanup] ***********************************************************
build.amazon-ebs.build: skipping: [default]
build.amazon-ebs.build:
build.amazon-ebs.build: TASK [aws : install AWS CLI] ***************************************************