Skip to content

python:3.15 breaks Ansible provisioner聽#13726

Open

Description

@tonyswu

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

We are running packer from a pre-built Docker image based on python:3. This started to break since the release of python:3.15 image (at the time of writing), with the following errors:

"failed preparing provisioner-block "ansible""

Reproduction Steps

  1. Docker pull python:3 (or python 3.15)
  2. Install ansible and other tools using pip
  3. Attempt to run packer with ansible provisioning block

Packer version

Tried both 1.11.2 and 1.16.1.

Simplified Packer Template

build {
  name = "name"
  sources = [
    "source.amazon-ebs.ami_build"
  ]

  {...}

  provisioner "ansible" {
    playbook_file    = var.ansible_playbook_name
    ansible_env_vars = [
      "ANSIBLE_DIFF_ALWAYS=1",
      "ANSIBLE_FORCE_COLOR=1"
    ]
    extra_arguments = [
      "-v",
    ]
    user      = var.ssh_username
    use_proxy = false
  }

  {...}
}

Operating system and Environment details

Build agent is based on python:3 Docker image.

Activity

  1. blacksoxx commented on Oct 22, 2026

    @blacksoxx

    I would like to work on this. I will track down what the python 3.15 image changes for the ansible provisioner's preparation step and make that step tolerant of it.

  2. blacksoxx commented on Oct 22, 2026

    @blacksoxx

    Reproduced with the python:3.14 and python:3.15 images, same ansible 14.5.0 / ansible-core 2.21.5 from pip. On 3.14 ansible-playbook --version prints the normal banner; on 3.15 every ansible command exits 1 before printing anything, with AttributeError: module 'dataclasses' has no attribute '_is_type' (CPython 3.15 removed that private helper). That is ansible/ansible#87677: Python 3.15 support starts with ansible-core 2.22, not backported to 2.21. So the workaround is python:3.14 (or ansible-core 2.22 once released); the provisioner itself only runs ansible-playbook --version.

    What the plugin did wrong is to drop ansible's stderr and show only "exit status 1". hashicorp/packer-plugin-ansible#277 appends the captured stderr to that error so the traceback shows up in the Packer diagnostic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions