Just dawned on me, the IP is also available as {{.HTTPIP}} as used in the
builder boot_command. Now whether this is available as where I am not
sure...
On Tuesday, 13 August 2019 10:09:56 UTC+1, Richard Payne wrote:
>
> Actually, the IP is in the standard output, not even debug.
>
> No idea how you're supposed to use that though.
>
> On Tuesday, 13 August 2019 08:37:49 UTC+1, Richard Payne wrote:
>>
>> I'm not seeing the IP in the log. However, it might provide some info on
>> what's wrong with the Ansible provisioner?
>>
>>
>> 2019/08/13 07:37:43 packer: 2019/08/13 07:37:43 [DEBUG] Password is
>> blank, will retry...
>> 2019/08/13 07:37:49 ui: amazon-ebs:
>> amazon-ebs: Password retrieved!
>> amazon-ebs:
>> amazon-ebs: Password retrieved!
>> ==> amazon-ebs: Waiting for WinRM to become available...
>> 2019/08/13 07:37:49 packer: 2019/08/13 07:37:49 Waiting for WinRM, up to
>> timeout: 30m0s
>> 2019/08/13 07:37:49 ui: ==> amazon-ebs: Waiting for WinRM to become
>> available...
>> 2019/08/13 07:37:54 packer: 2019/08/13 07:37:54 [INFO] Attempting WinRM
>> connection...
>> 2019/08/13 07:37:54 packer: 2019/08/13 07:37:54 [DEBUG] connecting to
>> remote shell using WinRM
>> 2019/08/13 07:38:01 ui: ==> amazon-ebs: Connected to WinRM!
>> 2019/08/13 07:38:01 packer: 2019/08/13 07:38:01 Running the provision hook
>> ==> amazon-ebs: Connected to WinRM!
>> 2019/08/13 07:38:01 [INFO] (telemetry) Starting provisioner ansible
>> 2019/08/13 07:38:01 ui: ==> amazon-ebs: Provisioning with Ansible...
>> ==> amazon-ebs: Provisioning with Ansible...
>> 2019/08/13 07:38:02 packer: 2019/08/13 07:38:02 SSH proxy: serving on
>> 127.0.0.1:36005
>> 2019/08/13 07:38:02 ui: ==> amazon-ebs: Executing Ansible:
>> ansible-playbook --extra-vars packer_build_name=amazon-ebs
>> packer_builder_type=amazon-ebs -i /tmp/packer-provisioner-ansible774557480
>> /home/richard/git/ansible/playbooks/windows_image_build/playbook.yml
>> --private-key /tmp/ansible-key713730989 --extra-vars {'environment_name':
>> 'packer', 'hosting_environment': 'aws', 'connection': 'packer'} --skip-tags
>> gitchecks --skip-tags gather_facts --skip-tags slack
>> ==> amazon-ebs: Executing Ansible: ansible-playbook --extra-vars
>> packer_build_name=amazon-ebs packer_builder_type=amazon-ebs -i
>> /tmp/packer-provisioner-ansible774557480
>> /home/richard/git/ansible/playbooks/windows_image_build/playbook.yml
>> --private-key /tmp/ansible-key713730989 --extra-vars {'environment_name':
>> 'packer', 'hosting_environment': 'aws', 'connection': 'packer'} --skip-tags
>> gitchecks --skip-tags gather_facts --skip-tags slack
>> 2019/08/13 07:38:03 ui: amazon-ebs: [WARNING]: Found variable using
>> reserved name: connection
>> amazon-ebs: [WARNING]: Found variable using reserved name: connection
>> amazon-ebs:
>> 2019/08/13 07:38:03 ui: amazon-ebs:
>> 2019/08/13 07:38:03 ui: amazon-ebs: PLAY [all]
>> *********************************************************************
>> amazon-ebs: PLAY [all]
>> *********************************************************************
>> 2019/08/13 07:38:03 ui: amazon-ebs:
>> amazon-ebs:
>> 2019/08/13 07:38:03 ui: amazon-ebs: TASK [Gathering Facts]
>> *********************************************************
>> amazon-ebs: TASK [Gathering Facts]
>> *********************************************************
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 SSH proxy: accepted
>> connection
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 authentication attempt
>> from 127.0.0.1:41696 to 127.0.0.1:36005 as richard using none
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 authentication attempt
>> from 127.0.0.1:41696 to 127.0.0.1:36005 as richard using publickey
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 new env request:
>> LANG=en_GB.UTF-8
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 new exec request: /bin/sh
>> -c 'echo ~richard && sleep 0'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] starting remote
>> command: /bin/sh -c 'echo ~richard && sleep 0'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] command '/bin/sh
>> -c 'echo ~richard && sleep 0'' exited with code: 1
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] RPC endpoint:
>> Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] 0 bytes written for 'stdout'
>> 2019/08/13 07:38:03 [INFO] 44 bytes written for 'stderr'
>> 2019/08/13 07:38:03 [INFO] RPC client: Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] RPC endpoint: Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] 0 bytes written for 'stdin'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 0 bytes written
>> for 'stdout'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 44 bytes written
>> for 'stderr'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] RPC client:
>> Communicator ended with: 1
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 0 bytes written
>> for 'stdin'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 new env request:
>> LANG=en_GB.UTF-8
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 new exec request: /bin/sh
>> -c 'echo "`pwd`" && sleep 0'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] starting remote
>> command: /bin/sh -c 'echo "`pwd`" && sleep 0'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] command '/bin/sh
>> -c 'echo "`pwd`" && sleep 0'' exited with code: 1
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] RPC endpoint:
>> Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] 44 bytes written for 'stderr'
>> 2019/08/13 07:38:03 [INFO] 0 bytes written for 'stdout'
>> 2019/08/13 07:38:03 [INFO] RPC client: Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] RPC endpoint: Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] 0 bytes written for 'stdin'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 0 bytes written
>> for 'stdout'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 44 bytes written
>> for 'stderr'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] RPC client:
>> Communicator ended with: 1
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 0 bytes written
>> for 'stdin'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 new env request:
>> LANG=en_GB.UTF-8
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 new exec request: /bin/sh
>> -c '( umask 77 && mkdir -p "` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `" && echo
>> ansible-tmp-1565678283.204747-204856165820508="` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `" ) && sleep
>> 0'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] starting remote
>> command: /bin/sh -c '( umask 77 && mkdir -p "` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `" && echo
>> ansible-tmp-1565678283.204747-204856165820508="` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `" ) && sleep
>> 0'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] command '/bin/sh
>> -c '( umask 77 && mkdir -p "` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `" && echo
>> ansible-tmp-1565678283.204747-204856165820508="` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `" ) && sleep
>> 0'' exited with code: 1
>> 2019/08/13 07:38:03 [INFO] 0 bytes written for 'stdout'
>> 2019/08/13 07:38:03 [INFO] 44 bytes written for 'stderr'
>> 2019/08/13 07:38:03 [INFO] RPC client: Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] RPC endpoint: Communicator ended with: 1
>> 2019/08/13 07:38:03 [INFO] 0 bytes written for 'stdin'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] RPC endpoint:
>> Communicator ended with: 1
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 0 bytes written
>> for 'stdout'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 44 bytes written
>> for 'stderr'
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] RPC client:
>> Communicator ended with: 1
>> 2019/08/13 07:38:03 packer: 2019/08/13 07:38:03 [INFO] 0 bytes written
>> for 'stdin'
>> 2019/08/13 07:38:03 ui: 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-1565678283.204747-204856165820508 `\" && echo
>> ansible-tmp-1565678283.204747-204856165820508=\"` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `\" ), exited
>> with result 1", "unreachable": true}
>> 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-1565678283.204747-204856165820508 `\" && echo
>> ansible-tmp-1565678283.204747-204856165820508=\"` echo
>> ~/.ansible/tmp/ansible-tmp-1565678283.204747-204856165820508 `\" ), exited
>> with result 1", "unreachable": true}
>> 2019/08/13 07:38:03 ui: amazon-ebs: to retry, use: --limit
>> @/home/richard/git/ansible/playbooks/windows_image_build/playbook.retry
>> amazon-ebs: to retry, use: --limit
>> @/home/richard/git/ansible/playbooks/windows_image_build/playbook.retry
>> amazon-ebs:
>> 2019/08/13 07:38:03 ui: amazon-ebs:
>> 2019/08/13 07:38:03 ui: amazon-ebs: PLAY RECAP
>> *********************************************************************
>> amazon-ebs: PLAY RECAP
>> *********************************************************************
>> 2019/08/13 07:38:03 ui: amazon-ebs: default :
>> ok=0 changed=0 unreachable=1 failed=0
>> amazon-ebs: default : ok=0 changed=0
>> unreachable=1 failed=0
>> 2019/08/13 07:38:03 ui: amazon-ebs:
>> amazon-ebs:
>>
>>
>>
>>
>>
>> On Monday, 12 August 2019 16:24:02 UTC+1, deanwarrenuk wrote:
>>>
>>> Doesn't the PACKER_LOG show the ip/port info?
>>>
>>> On Mon, Aug 12, 2019 at 4:09 PM 'Richard Payne' via Packer <
>>> [email protected]> wrote:
>>>
>>>> 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
>>>>
>>>> <https://groups.google.com/d/msgid/packer-tool/9eb4db18-0ea0-478c-a569-ba4adda97b84%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
--
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/5fad7ba6-c4f7-4c5c-830f-bf8be1eb59d2%40googlegroups.com.