Skip to content

Module.run does not run the way described in the documentation #56422

@jtraub91

Description

@jtraub91

Description of Issue

The documentation located here describes the new and legacy style of passing arguments when using the module.run state function. However, the new style does not behave as described and the legacy style provides a warning that this will be deprecated in the Sodium release. This can be frustrating for users.

Setup

Normal salt installation. Create the following test state to demonstrate.

# test.sls

test_new_style_module_run:
  module.run:
    - test.random_hash:
      - size: 42
      - hash_type: sha256

test_legacy_style_module_run:
  module.run:
    - name: test.random_hash
    - size: 42
    - hash_type: sha256

Steps to Reproduce Issue

Run the state.

# salt \* state.apply test
ip-10-10-10-199.us-west-2.compute.internal:
----------
          ID: test_new_style_module_run
    Function: module.run
      Result: False
     Comment: Module function test_new_style_module_run is not available
     Started: 22:09:13.200256
    Duration: 1.247 ms
     Changes:
----------
          ID: test_legacy_style_module_run
    Function: module.run
        Name: test.random_hash
      Result: True
     Comment: Module function test.random_hash executed
     Started: 22:09:13.201689
    Duration: 35.354 ms
     Changes:
              ----------
              ret:
                  76a50887d8f1c2e9301755428990ad81479ee21c25b43215cf524541e0503269

Summary for ip-10-10-10-199.us-west-2.compute.internal
------------
Succeeded: 1 (changed=1)
Failed:    1
------------
Total states run:     2
Total run time:  36.601 ms
ERROR: Minions returned with non-zero exit code

Even in the successful case, the logs warn the user that this will be deprecated in Sodium.

# tail /var/log/salt/minion
2020-03-20 14:05:57,901 [salt.utils.decorators:636 ][WARNING ][12968] The function "module.run" is using its deprecated version and will expire in version "Sodium".
2020-03-20 14:05:57,901 [salt.state       :322 ][ERROR   ][12968] Module function yo is not available
2020-03-20 14:06:31,797 [salt.utils.decorators:636 ][WARNING ][13042] The function "module.run" is using its deprecated version and will expire in version "Sodium".
2020-03-20 14:06:31,798 [salt.state       :322 ][ERROR   ][13042] Module function yo is not available
2020-03-20 22:07:21,986 [salt.utils.decorators:636 ][WARNING ][9056] The function "module.run" is using its deprecated version and will expire in version "Sodium".
2020-03-20 22:07:21,988 [salt.state       :322 ][ERROR   ][9056] Module function test_new_style_module_run is not available
2020-03-20 22:08:41,383 [salt.state       :3607][CRITICAL][9130] Rendering SLS 'base:test' failed: mapping values are not allowed in this context
2020-03-20 22:09:13,201 [salt.utils.decorators:636 ][WARNING ][9146] The function "module.run" is using its deprecated version and will expire in version "Sodium".
2020-03-20 22:09:13,201 [salt.state       :322 ][ERROR   ][9146] Module function test_new_style_module_run is not available
2020-03-20 22:09:13,202 [salt.utils.decorators:636 ][WARNING ][9146] The function "module.run" is using its deprecated version and will expire in version "Sodium".

Versions Report

# salt --versions-report
Salt Version:
           Salt: 3000

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
       M2Crypto: 0.33.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.8 (default, Aug  7 2019, 17:28:10)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.7.1908 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1062.12.1.el7.x86_64
         system: Linux
        version: CentOS Linux 7.7.1908 Core

Metadata

Metadata

Assignees

No one assigned

    Labels

    cannot-reproducecannot be replicated with info/context provided

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions