Closed
Description
Overview of the Issue
After running an Ansible playbook that performs update-crypto-policies --set FIPS
and reboots an RHEL8 AWS instance, packer cannot reconnect to the instance.
Reproduction Steps
git clone https://gist.github.com/19d6e0abbea44001c5d1c4e409e29dd8.git
cd 19d6e0abbea44001c5d1c4e409e29dd8
- Update
ssh_keypair_name
andssh_private_key_file
inaws-ebs-ansible.json
for an existing AWS key pair. The issue will manifest if packer creates a temporary ssh keypair but if you use an existing pair, you can ssh to the directly instance even when packer cannot. packer build -var-file vars-rhel8.json aws-ebs-ansible.json
- Observe that packer cannot reconnect to after the system-wide policy is updated and the instance is rebooted (see debug.log for complete log):
.
.
.
amazon-ebs: changed: [default]
amazon-ebs:
amazon-ebs: TASK [Wait for reboot to complete] *********************************************
amazon-ebs: ok: [default -> localhost]
amazon-ebs:
amazon-ebs: TASK [Get uptime] **************************************************************
2020/01/15 07:11:10 packer-provisioner-ansible plugin: SSH proxy: accepted connection
2020/01/15 07:11:10 packer-provisioner-ansible plugin: authentication attempt from 127.0.0.1:42116 to 127.0.0.1:37060 as ec2-user using none
2020/01/15 07:11:10 packer-provisioner-ansible plugin: authentication attempt from 127.0.0.1:42116 to 127.0.0.1:37060 as ec2-user using publickey
2020/01/15 07:11:10 packer-provisioner-ansible plugin: new env request: LANG=en_US.UTF-8
2020/01/15 07:11:10 packer-provisioner-ansible plugin: new exec request: /bin/sh -c 'echo ~ec2-user && sleep 0'
2020/01/15 07:11:10 packer-builder-amazon-ebs plugin: [DEBUG] Opening new ssh session
2020/01/15 07:11:10 packer-builder-amazon-ebs plugin: [ERROR] ssh session open error: 'EOF', attempting reconnect
2020/01/15 07:11:10 packer-builder-amazon-ebs plugin: [DEBUG] reconnecting to TCP connection for SSH
2020/01/15 07:11:10 packer-builder-amazon-ebs plugin: [DEBUG] handshaking with SSH
2020/01/15 07:11:10 [INFO] 0 bytes written for 'stdout'
2020/01/15 07:11:10 [INFO] 0 bytes written for 'stderr'
2020/01/15 07:11:10 [INFO] 0 bytes written for 'stdin'
2020/01/15 07:11:10 packer-provisioner-ansible plugin: [INFO] 0 bytes written for 'stdout'
2020/01/15 07:11:10 packer-provisioner-ansible plugin: [INFO] 0 bytes written for 'stderr'
==> amazon-ebs: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
.
.
.
- packer hangs at this point but I can use ssh to the AWS instance directly (
[email protected]
) using my existing private key. - Use Ctrl-C to bring stop packer and clean up the AWS temporary instance
Packer version
Packer v1.5.1
Simplified Packer Buildfile
Operating system and Environment details
Driving system is CentOS 7 (3.10.0-957.27.2.el7.x86_64
)