saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.13k stars 5.47k forks source link

[BUG] State 'pkg.installed' was not found #57490

Closed gaozhekang closed 3 years ago

gaozhekang commented 4 years ago

Description I got a problem when using salt on openEuler linux(both master and minion), which is an opensource linux system and uses rpm for pkg management & systemd for service management, like what Centos do.

It reports an error as ”State 'pkg.installed' was not found”. I guess it's because openEuler systems can not be recognized, while it's very similar to Centos or fedora. So is there some way I can tell salt that the system is centos-like, or that rpm and systemd are used on this system?

Or maybe this can be fixed? I really like Salt because it's arch independent and has detailed documents, so that I can easily manage my systems.

Setup

top.sls
base:
  '*':
     - system
system.sls
auditd:
    pkg.installed: []
    service.running:
        - require:
            - pkg: audit

Steps to Reproduce the behavior

$ salt '*' state.apply
m1:
    ----------
    pkg_|-auditd_|-auditd_|-installed:
        ----------
        __run_num__:
            0
        changes:
            ----------
        comment:
            **State 'pkg.installed' was not found in SLS 'system'**
            **Reason: Module 'pkg' is not available.**
        name:
            auditd
        result:
            False
    service_|-auditd_|-auditd_|-running:
        ----------
        __run_num__:
            1
        __sls__:
            system
        changes:
            ----------
        comment:
            **The following requisites were not found:
                               require:
                                   pkg: audit**
        result:
            False

Versions Report

salt --versions-report ``` salt-call --versions-report Salt: 2015.5.10 Python: 2.7.16 (default, Mar 23 2020, 19:07:51) Jinja2: 2.10 M2Crypto: 0.30.1 msgpack-python: 0.5.6 msgpack-pure: Not Installed pycrypto: 2.6.1 libnacl: Not Installed PyYAML: 5.1.2 ioflo: Not Installed PyZMQ: 14.7.0 RAET: Not Installed ZMQ: 4.1.4 Mako: Not Installed Tornado: Not Installed timelib: Not Installed dateutil: Not Installed ```

Additional context The system info is :

$ salt-call --local grains.get os_family
local:
    openEuler
gaozhekang commented 4 years ago

ISO can be downloaded here(If this can do help) https://repo.openeuler.org/openEuler-20.03-LTS/

Akm0d commented 4 years ago

Since the os_family is "openEuler" the change probably just needs to be made to yumpkg.py's virtual function:

Specifically:

    enabled = ("amazon", "xcp", "xenserver", "virtuozzolinux", "virtuozzo")

Needs to be changed to

    enabled = ("amazon", "openEuler", "xcp", "xenserver", "virtuozzolinux", "virtuozzo")

Would you like to open a PR for that change?

gaozhekang commented 4 years ago

Since the os_family is "openEuler" the change probably just needs to be made to yumpkg.py's virtual function:

Specifically:

    enabled = ("amazon", "xcp", "xenserver", "virtuozzolinux", "virtuozzo")

Needs to be changed to

    enabled = ("amazon", "openEuler", "xcp", "xenserver", "virtuozzolinux", "virtuozzo")

Would you like to open a PR for that change?

It solves the problem. Very grateful! I'm ready to open a PR for my code and spec adaption on openEuler. But salt I'm using is an old version released in 2015. I'm not clear that if the same adaption on master branch is effective, I will have a test before that, so see you soon!

prg318 commented 3 years ago

This is also an issue for CentOS 8 Stream minions.

CentOS 8 Stream os_family:

$ salt-call --local grains.get os_family
local:
    CentOS Stream

salt-minion log when attempting to use pkg.installed on a CentOS 8 Stream minion:

[ERROR   ] State 'pkg.installed' was not found in SLS 'pkg'                                                  
Reason: 'pkg' __virtual__ returned False: pkg module could not be loaded

I'm not sure if CentOS 8 Stream's os_family should be set to Redhat (like CentOS 7 was) or if CentOS Stream should be added to this enable list

nikAizuddin commented 3 years ago

I'm also having the same issue with CentOS 8 Stream:

[vagrant@windefender-box ~]$ sudo salt-call state.sls cockpit.package
[INFO    ] Loading fresh modules for state activity
[INFO    ] Executing command ['git', '--version'] in directory '/root'
[INFO    ] Running state [cockpit-and-addons-present] at time 10:29:41.276228
[ERROR   ] State 'pkg.installed' was not found in SLS 'cockpit.package.present'
Reason: 'pkg' __virtual__ returned False: pkg module could not be loaded

local:
----------
          ID: cockpit-and-addons-present
    Function: pkg.installed
      Result: False
     Comment: State 'pkg.installed' was not found in SLS 'cockpit.package.present'
              Reason: 'pkg' __virtual__ returned False: pkg module could not be loaded
     Changes:   

Summary for local
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   0.000 ms
[vagrant@windefender-box ~]$

Versions Report

salt-call --versions-report ``` [vagrant@windefender-box ~]$ sudo salt-call --versions-report Salt Version: Salt: 3002.2 Dependency Versions: cffi: Not Installed cherrypy: Not Installed dateutil: 2.6.1 docker-py: Not Installed gitdb: Not Installed gitpython: Not Installed Jinja2: 2.11.2 libgit2: Not Installed M2Crypto: Not Installed Mako: Not Installed msgpack: 1.0.2 msgpack-pure: Not Installed mysql-python: Not Installed pycparser: Not Installed pycrypto: Not Installed pycryptodome: 3.9.9 pygit2: Not Installed Python: 3.6.8 (default, Dec 3 2020, 18:11:24) python-gnupg: Not Installed PyYAML: 5.3.1 PyZMQ: 20.0.0 smmap: Not Installed timelib: Not Installed Tornado: 4.5.3 ZMQ: 4.3.3 System Versions: dist: centos 8 locale: UTF-8 machine: x86_64 release: 4.18.0-257.el8.x86_64 system: Linux version: CentOS Stream 8 ```