Skip to content

ansible_port variable is not evaluated #978

@anxstj

Description

@anxstj

I pass a nested variable to Ansible to determine the connection port in a dynamic way. This has worked with Ansible-core 2.11 and mitogen and Ansible-core 2.13 without mitogen, but it doesn't work with Ansible-core 2.13 and mitogen.

  • Which version of Ansible are you running?
ansible [core 2.13.7]
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/devenv-6/lib/python3.11/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/devenv-6/bin/ansible
  python version = 3.11.0 (main, Oct 24 2022, 00:00:00) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)]
  jinja version = 3.0.3
  libyaml = False
  • Is your version of Ansible patched in any way?: No
  • Are you running with any custom modules, or module_utils loaded? No
  • Have you tried the latest master version from Git? Yes
  • Mention your host and target OS and versions: Host: Fedora 37; Target: Debian 11
  • Mention your host and target Python versions: see above

Playbook to reproduce the issue:

---
- hosts: all
  strategy: mitogen_linear

  vars:
    other_port: 22
    ansible_port: "{{ other_port }}"   # didn't work either: "{{ '22' }}"
  tasks:
    - debug: var=ansible_port

Command to reproduce the issue:

ansible-playbook -i myhost, playbook.yml

Actual output:

TASK [Gathering Facts] **********************************************************
[WARNING]: Unhandled error in Python interpreter discovery for host myhost: EOF on stream; last 100 lines received: Bad port '{{
other_port }}'
fatal: [myhost]: UNREACHABLE! => {"changed": false, "msg": "EOF on stream; last 100 lines received:\nBad port '{{ other_port }}'", "unreachable": true}

Expected output (as with strategy=linear):

TASK [Gathering Facts] *****************************************************************************
ok: [myhost]

TASK [debug] *************************************************************************************
ok: [myhost] => {
    "ansible_port": "22"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-0.3Issues related to 0.3.X Mitogen releasesbugCode feature that hinders desired execution outcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions