Ansible provisionner hangs


I’m sorry but I have problem from long time with packer.
Provisionning hangs, I have to “ctrl+c” to exit.

Today, I try on fresh Ubuntu Focal install, but same problem.

Ubuntu 20.04
Packer 1.60
Ansible 2.9.11


    "variables": {
    "builders": [
          "type": "lxd",
          "name": "ubuntu-2004-qw",
          "image": "ubuntu-minimal:focal",
          "output_image": "ubuntu-2004-qw",
          "publish_properties": {
            "description": "Image LXD ubuntu bionic ansible ready"
    "provisioners": [
        "type": "ansible",
        "user": "root",
        "playbook_file": "config.yml",
        "extra_arguments": ["-vvvv"]


- hosts: default
  become: yes
    ansible_python_interpreter: "/usr/bin/python3"
  gather_facts: no
    - name: Ajout user ansible avec cle ssh
        name: ansible
        comment: Ansible user
        system: yes

    - name: Set up multiple authorized keys
        user: ansible
        state: present
        key: '{{ item }}'
        - ssh-xxxxxx
        - ssh-xxxxxx


PACKER_DEBUG=1 packer build ansible.json
ubuntu-2004-qw: output will be in this color.

==> ubuntu-2004-qw: Creating container...
==> ubuntu-2004-qw: Provisioning with Ansible...
    ubuntu-2004-qw: Setting up proxy adapter for Ansible....
==> ubuntu-2004-qw: Executing Ansible: ansible-playbook -e packer_build_name=ubuntu-2004-qw -e packer_builder_type=lxd -e packer_http_addr=ERR_HTTP_ADDR_NOT_IMPLEMENTED_BY_BUILDER -vvvv -e ansible_ssh_private_key_file=/tmp/ansible-key074176145 -i /tmp/packer-provisioner-ansible384870076 /home/ansible/config.yml
    ubuntu-2004-qw: ansible-playbook 2.9.11
    ubuntu-2004-qw:   config file = None
    ubuntu-2004-qw:   configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
    ubuntu-2004-qw:   ansible python module location = /home/ansible/.local/lib/python3.8/site-packages/ansible
    ubuntu-2004-qw:   executable location = /home/ansible/.local/bin/ansible-playbook
    ubuntu-2004-qw:   python version = 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
    ubuntu-2004-qw: No config file found; using defaults
    ubuntu-2004-qw: setting up inventory plugins
    ubuntu-2004-qw: host_list declined parsing /tmp/packer-provisioner-ansible384870076 as it did not pass its verify_file() method
    ubuntu-2004-qw: script declined parsing /tmp/packer-provisioner-ansible384870076 as it did not pass its verify_file() method
    ubuntu-2004-qw: auto declined parsing /tmp/packer-provisioner-ansible384870076 as it did not pass its verify_file() method
    ubuntu-2004-qw: Parsed /tmp/packer-provisioner-ansible384870076 inventory source with ini plugin
    ubuntu-2004-qw: Loading callback plugin default of type stdout, v2.0 from /home/ansible/.local/lib/python3.8/site-packages/ansible/plugins/callback/
    ubuntu-2004-qw: PLAYBOOK: config.yml ***********************************************************
    ubuntu-2004-qw: Positional arguments: /home/ansible/config.yml
    ubuntu-2004-qw: verbosity: 4
    ubuntu-2004-qw: connection: smart
    ubuntu-2004-qw: timeout: 10
    ubuntu-2004-qw: become_method: sudo
    ubuntu-2004-qw: tags: ('all',)
    ubuntu-2004-qw: inventory: ('/tmp/packer-provisioner-ansible384870076',)
    ubuntu-2004-qw: extra_vars: ('packer_build_name=ubuntu-2004-qw', 'packer_builder_type=lxd', 'packer_http_addr=ERR_HTTP_ADDR_NOT_IMPLEMENTED_BY_BUILDER', 'ansible_ssh_private_key_file=/tmp/ansible-key074176145')
    ubuntu-2004-qw: forks: 5
    ubuntu-2004-qw: 1 plays in /home/ansible/config.yml
    ubuntu-2004-qw: PLAY [default] *****************************************************************
    ubuntu-2004-qw: META: ran handlers
    ubuntu-2004-qw: TASK [Ajout user ansible avec cle ssh] *****************************************
    ubuntu-2004-qw: task path: /home/ansible/config.yml:8
    ubuntu-2004-qw: <> ESTABLISH SSH CONNECTION FOR USER: root
    ubuntu-2004-qw: <> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=37759 -o 'IdentityFile="/tmp/ansible-key074176145"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/home/ansible/.ansible/cp/d9b3ed108b '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''

And it’s stuck.

What I can do?

Exactly the same problem here, with 2 playbooks, except that it is always the last task of the last playbook that fails, and it hangs for 2 hours, sharp.
I tried swapping them to no avail.
Downgraded to ansible 2.7.10 => Nope
Packer 1.4.1 => 1.6.1 => Nope

Solution: only one wrapping playbook with multiple roles => works a s a charm

@ quanticware try setting "no_proxy": "true" in the ansible provisioner config.