"AnsiballZ_setup.py: No such file or directory"

Hey there!

I’m upgrading my build agents from Amazon Linux 2 to Amazon Linux 2023. This includes an upgrade from ansible 2.9.23/python 2.7.18 (!!) to ansible 2.15.3/python 3.9.16.

I’m getting an error when running the new version of Ansible - it’s failing during the Gathering Facts stage. Here’s a link to the cleaned-up logs with ANSIBLE_VERBOSITY=4: ansible.log · GitHub

It seems like this is the relevant error:

	debug1: Couldn't stat remote file: No such file or directory
	debug3: source_sftp: copying local /home/ec2-user/.ansible/tmp/ansible-local-33222mc2zdwp/tmp0asestpp to remote '~ec2-user/.ansible/tmp/ansible-tmp-1724093332.1204538-3326-37864137221757/AnsiballZ_setup.py'
	debug3: Sent dest message SSH2_FXP_OPEN I:2 P:'~ec2-user/.ansible/tmp/ansible-tmp-1724093332.1204538-3326-37864137221757/AnsiballZ_setup.py' M:0x001a
	dest open(\"'~ec2-user/.ansible/tmp/ansible-tmp-1724093332.1204538-3326-37864137221757/AnsiballZ_setup.py'\"): No such file or directory
	failed to upload file /home/ec2-user/.ansible/tmp/ansible-local-33222mc2zdwp/tmp0asestpp to '~ec2-user/.ansible/tmp/ansible-tmp-1724093332.1204538-3326-37864137221757/AnsiballZ_setup.py'
	debug3: mux_client_read_packet: read header failed: Broken pipe
	debug2: Control master terminated unexpectedly

It seems like Ansible isn’t able to copy AnsiballZ_setup.py to the target. From what I can tell, we are able to authenticate to the target, though:

	debug1: Sending command: /bin/sh -c \'echo ~ec2-user && sleep 0\'
        [...]
	debug2: set_control_persist_exit_time: schedule exit in 60 seconds
	debug2: Received exit status from master 0

But, for some reason, Ansible can’t copy the file over.

I know it complicates the question, but if it’s at all relevant - this is a Jenkins build agent, running Packer’s “ansible” provisioner, against an Amazon EC2 instance.

I’d appreciate any help with next steps on troubleshooting the issue! Happy to share further details of my infrastructure if needed.