Salt: Object Oriented Utility modules Do Not Work

Created on 25 Oct 2019  路  5Comments  路  Source: saltstack/salt

Description of Issue

The ability to include 'utility modules' is documented here. The feature currently does not seem to support including modules by importing, as discussed in the latter half (object oriented modules). Also, the documentation is unclear since in the example they import mymodule but it is never mentioned where the name mymodule comes from.

Setup

Normal salt installation. No unique configuration.

Steps to Reproduce Issue

use the example in the docs

# /srv/salt/_utils/mymodule.py

class Foo(object):

    def __init__(self):
        pass

    def bar():
        return 'baz'
# /srv/salt/_modules/utils_issue.py
import mymodule

def observe_the_awesomeness():
    foo = mymodule.Foo()
    return foo.bar()



md5-652e067b05a27bf8ccb693f41f651941



# salt \* saltutil.sync_all



md5-652e067b05a27bf8ccb693f41f651941



salt \* utils_issue.observe_the_awesomeness
minion1:
    'utils_issue' __virtual__ returned False: No module named mymodule



md5-54d5df27c9ebb62f37e8059cd904d02c



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

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: 2.0.5
      gitpython: 2.1.11
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.31.0
           Mako: 1.0.7
   msgpack-pure: Not Installed
 msgpack-python: 0.5.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.16 (default, Oct  7 2019, 17:36:04)
   python-gnupg: 0.4.3
         PyYAML: 3.13
          PyZMQ: 17.1.2
           RAET: Not Installed
          smmap: 2.0.5
        timelib: Not Installed
        Tornado: 5.1.1
            ZMQ: 4.3.1

System Versions:
           dist: Ubuntu 19.04 disco
         locale: UTF-8
        machine: x86_64
        release: 5.0.0-25-generic
         system: Linux
        version: Ubuntu 19.04 disco
Bug fixed-pending-your-verification

All 5 comments

@jtraub91 Thank you for reporting this issue.

I am seeing the same thing as you, but I am not very familiar with this module, so would like to ask someone on the core team to take a look also.

@saltstack/team-core Can one of you take a look at this, thanks.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

Still seeing this issue in 2019.2.5.

Interestingly, it works using "salt-call" directly when logged into the minion host.

@clallen this is fixed by e5b3e87e55dc512705ff6155b4086add742454f5
This will be released with Salt 3001

Was this page helpful?
0 / 5 - 0 ratings