Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible provisioner fails with "failed to transfer file" #110

Open
hc-github-team-packer opened this issue Jul 29, 2022 · 4 comments
Open

Comments

@hc-github-team-packer
Copy link

This issue was originally opened by @stefangweichinger in hashicorp/packer#11783 and has been migrated to this repository. The original issue description is below.


Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

I have a packer config using the virtualbox-iso builder for building Debian VMs.
This config uses the ansible provisioner and worked fine before.

Recently I see failed builds because the provisioning step fails:

2022/05/17 07:51:59 ui:     debian.virtualbox-iso.bullseye: failed to transfer file to /home/sgw/.ansible/tmp/ansible-local-45402qjbtzya8/tmpeyxtinre /home/vagrant/.ansible/tmp/ansible-tmp-1652766718.7643352-45407-8201740687254/AnsiballZ_setup.py:

Reproduction Steps

Run "packer build" with a packer build using the ansible provisioner.

Packer version

1.8.0

Simplified Packer Template

the part with the provisioner:

  provisioner "ansible" {
    playbook_file = "ansible/vagrant-debian-11-guest-additions.yml"
    user          = "${var.ssh_username}"
    ansible_env_vars = [
      "ANSIBLE_STDOUT_CALLBACK=debug",
      "ANSIBLE_HOST_KEY_CHECKING=False",
      "ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s'",
      "ANSIBLE_NOCOLOR=True"
      ]
    ansible_ssh_extra_args = [
      "-o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa"
    ]
  }

These extra_args come from fixing an issue with ssh not able to log into the created VM.
If I comment these vars it fails as well, but with another issue around "host key type" (yes, I found the related issue, that's where my extra_vars come from).

Operating system and Environment details

Fedora 36 Workstation, VirtualBox 6.1.34

 ansible --version
ansible [core 2.12.3]
  config file = None
  configured module search path = ['/home/sgw/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/sgw/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/sgw/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/sgw/.local/bin/ansible
  python version = 3.10.4 (main, Mar 25 2022, 00:00:00) [GCC 12.0.1 20220308 (Red Hat 12.0.1-0)]
  jinja version = 3.0.3
  libyaml = True
@mtumalewicz
Copy link

mtumalewicz commented Aug 5, 2022

After some testing with solution presented in: hashicorp/packer#11783 (comment)
I think that it might be painfull to manage additional logic at top of packerfiles to determine versions of openssh and provide scp legacy flag or not.

To handle it properly use ssh_transfer_method = smart or ssh_transfer_method = piped in your ansible config - ansible docs.

@onitake
Copy link

onitake commented Sep 2, 2022

This seems to be same issue as #100 .

hashicorp/packer#11783 (comment) mentioned another workaround: Add extra_arguments = [ "--scp-extra-args", "'-O'" ] to the provisioner.

ssh_transfer_method = smart should look like this, if you put it into your ansible.cfg:

[ssh_connection]
transfer_method = smart

This will work, but generate lots of warnings.

@hswong3i
Copy link

hswong3i commented Nov 14, 2022

My ansible.cfg working with Ubuntu 22.10 + openssh-server 9.0p1:

[ssh_connection]
control_path = %(directory)s/%%h-%%p-%%r
pipelining = true
scp_extra_args = -O
scp_if_ssh = true
ssh_args = -o ControlMaster=auto -o ControlPersist=600s
transfer_method = smart

[defaults]
ansible_managed = Ansible managed: Do NOT edit this file manually!
display_failed_stderr = true
forks = 20
host_key_checking = false
interpreter_python = auto
nocows = 1
remote_tmp = $HOME/.ansible/tmp
retry_files_enabled = false

hswong3i added a commit to alvistack/ansible-role-ansible that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-audacity that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-audacious that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-bamboo that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-bootstrap that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-bitbucket that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-bleachbit that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-catatonit that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-buildah that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-blender that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-ceph_mds that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-ceph_common that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-ceph_osd that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-code that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-chrome that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-ceph_mgr that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-clamav that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-ceph_rgw that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-cilium that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-cloud_init that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-chrony that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-conmon that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-cri_o that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-confluence that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-containernetworking_plugins that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/ansible-role-containers_common that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-dnsmasq that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-gitlab-ee that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-gitlab-ce that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-fisheye that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-httpd that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-jira that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-mariadb that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-opensuse that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-mitmproxy that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-rhel that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-php-fpm that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-postgres that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-postfix that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-debian that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-centos that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-ceph that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/docker-ubuntu that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-devel that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-fedora that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-kubernetes that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-opensuse that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-rhel that referenced this issue Nov 14, 2022
hswong3i added a commit to alvistack/vagrant-ubuntu that referenced this issue Nov 14, 2022
@samgrewal
Copy link

samgrewal commented Nov 15, 2022

Also seeing this issue with packer 1.8.4 against RHEL 8.6 + OpenSSH 8.0p1

The specific error message:
Failed to connect to the host via scp: bash: /usr/lib/sftp-server: No such file or directory\nscp: Connection closed\r\n

Minimum change to resolve was adding extra_arguments = [ "--scp-extra-args", "'-O'" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants