mitogen icon indicating copy to clipboard operation
mitogen copied to clipboard

Could mitogen_via be templated?

Open Chostakovitch opened this issue 1 month ago • 0 comments

Description

Hey there! Thanks for this awesome software.

I stumbled across a few issues and I understood that not all inventory variables can be templated (is this the case? If so, is there a reason for this?)

I have a use case where every Ansible connection should be delegated to a bastion, except for the bastion itself. But I also want to let the ability to launch playbooks directly from the bastion, because this is the way other sysadmins use to do.

I initially thought something like:

# host_vars/bastion.yaml
mitogen_via: null
# group_vars/all.yaml
mitogen_via: "{{ 'user@bastion' if jump else null }}"

would do, allowing to switch between home-originating and bastion-originating by passing -e jump=true on the command line.

But I get the message 'Task failed: A required TemplateContext context is not active. on the first task launched across a different host than the bastion, e.g.

Could you help me to understand, or point me in another direction to achieve something similar? Thanks in advance!

Mitogen version

0.3.34

Ansible version (if applicable)

2.19.3

OS and environment

Arch Linux, Python 3.13.7

Steps to reproduce

Given the configuration above, something like:

# playbooks/test.yml
---
- name: "Get ping response"
  hosts: all
  gather_facts: false
  tasks:
    - ping:

command:

ansible-playbook playbook/test.yml -l <HOST> -e jump=true

Anything else

No response

Chostakovitch avatar Nov 27 '25 15:11 Chostakovitch