Skip to content

[DOCS] document Module.run usage with pyobjects renderer #61828

Closed as not planned

Description

@nicholasmhughes

Description
The new module.run format which will be enforced on the release of 3005 throws a little bit of a monkey wrench in the pyobjects renderer. The new format expects the name of the module to run as one of the keyword arguments, but it can't be listed explicitly in the pyobjects format because of the dot (.) in the name.

Attempting to run something like this:

#!pyobjects

user = ["susan"]
Module.run("pyobject_shadow", shadow.lock_password=user)

will fail with an error like this:

local:
    Data failed to compile:
----------
    Rendering SLS py_shadow failed, render error: keyword can't be an expression (<string>, line 4)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/state.py", line 4034, in render_state
    context=context,
  File "/usr/lib/python3/dist-packages/salt/template.py", line 99, in compile_template
    ret = render(input_data, saltenv, sls, **render_kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 149, in __call__
    return self.loader.run(run_func, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1201, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/loader/lazy.py", line 1216, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/salt/renderers/pyobjects.py", line 495, in render
    exec(final_template, _globals)
  File "<string>", line 4
SyntaxError: keyword can't be an expression

However, creating a kwargs dictionary seems to work just fine:

#!pyobjects

lock_kwargs = {"shadow.lock_password": ["susan"]}
Module.run("pyobject_shadow", **lock_kwargs)

Suggested Fix
A brief section with code examples such as above should point folks in the right direction.

Location or format of documentation
Might be a good fit in either or both of the pyobjects docs and module.run docs.

Additional context
This probably won't affect many people as I suspect the intersection of people using both pyobjects and module.run is small.

Activity

  1. added
    documentation
    on Mar 22, 2022
  2. whytewolf commented on Mar 22, 2022

    @whytewolf
    Collaborator

    for clarification. per #58763 neither syntax of module.run is going away. we are instead going to do a detect and run style and make use_superseded a noop

  3. nicholasmhughes commented on Mar 22, 2022

    @nicholasmhughes
    ContributorAuthor

    Oh nice! Thanks for letting me know @whytewolf

  4. added this to the Approved milestone on Mar 31, 2022
  5. removed their assignment
    on Mar 31, 2022
  6. added
    severity-low
    help-wanted
    on Apr 11, 2022
  7. dwoz commented on Oct 15, 2026

    @dwoz
    Contributor

    Thanks for the original report. This issue has been open for more than three years without recent activity and carries a severity label below severity-high. As part of a backlog cleanup, we're closing older low- and medium-severity issues so triage can focus on reports against currently supported releases.

    Closing isn't a judgement that the problem wasn't real — only that the codebase has moved through several releases since this was filed, and much of the surrounding code has changed.

    If you — or anyone else — can still reproduce this on the 3008.x LTS release, please leave a comment with a reproduction and a maintainer will reopen. The original reporter can also reopen directly.

  8. dwoz commented on Oct 17, 2026

    @dwoz
    Contributor

    Reopening — there is an open PR tracking a fix for this: #69560.

  9. reopened this on Oct 17, 2026
  10. dwoz commented on Oct 28, 2026

    @dwoz
    Contributor

    Closing — consolidated into #70585. The checkbox for this item is in the appropriate theme section of that tracker. Please pick up the sub-item there.

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

    documentationhelp-wantedseverity-lowtime-estimate-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions