Skip to content

ansible_mitogen: Evolution of NewStylePlanner ALWAYS_FORK_MODULES #1333

@moreati

Description

@moreati

ansible_mitogen.planner.NewStylePlanner.ALWAYS_FORK_MODULES is a frozenset of Ansible module names (full qualified and unqualified) the Mitogen should treat as single-shot. The in-memory imported Python module cannot be reused, thus Mitogen must reinstantiate it each time.

#: Module names appearing in this set always require forking, usually due
#: to some terminal leakage that cannot be worked around in any sane
#: manner.
ALWAYS_FORK_MODULES = frozenset([
'dnf', # issue #280; py-dnf/hawkey need therapy
'firewalld', # issue #570: ansible module_utils caches dbus conn
'ansible.legacy.dnf', # issue #776
'ansible.builtin.dnf', # issue #832
'freeipa.ansible_freeipa.ipaautomember', # issue #1216
'freeipa.ansible_freeipa.ipaautomountkey',
'freeipa.ansible_freeipa.ipaautomountlocation',

Problems

  • Bad name: ALWAYS_FORK describes an implementation detail, not the intent/purpose
  • Bad API: exposes an implementation detail
  • Brittle: the list is long, incomplete, and static
  • High maintenance: fixing a particular instance requires a PR and release cycle
  • Obscure: it is very unobvious that aparticular Ansible failure has any connection with ALWAYS_FORK_MODULES

Ideas

  • Seal implementation behind methods/properties
  • Fully qualify names before checking them (e.g. dnf vs ansible.legacy.dnf vs ansible.builtin.dnf)
  • Make configurable (e.g. environment variable, Ansible plugin property)
  • Mechanism for Ansible modules to declare themself multi or single shot (e.g. class attribute mitogen_reuse = True|False|None)
  • Provide extension mechanism(s)

refs #1216, #1255, #1327

Metadata

Metadata

Assignees

No one assigned

    Labels

    DesignRequiredIssues that cannot progress due to incomplete designaffects-0.3Issues related to 0.3.X Mitogen releases

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions