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.14k stars 5.47k forks source link

root user , 'dmidecode' warning #39184

Closed akumacxd closed 7 years ago

akumacxd commented 7 years ago

When starting the salt-master in the SUSE11SP4 environment, the following warning is printed: 2017-02-05 20:51:48,811 [salt.loaded.int.grains.core ][WARNING ][10593] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate. 2017-02-05 20:51:48,848 [salt.loaded.int.grains.core ][WARNING ][10607] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.

salt --version

salt 2016.3.4 (Boron)

akumacxd commented 7 years ago

rpm -qa | grep python

python-numpy-1.8.0-0.11.1 python-gtk-2.16.0-1.1.251 apache2-mod_python-3.3.1-147.24.104 python-xml-2.6.9-39.1 python-futures-3.0.5-23.1 python-gevent-1.1.2-31.2 python-dmidecode-3.10.11-0.12.1 python-pywbem-0.7-6.22.1 dbus-1-python-0.83.0-27.1.43 python-gtksourceview-2.4.0-1.32 python-curl-7.19.0-5.2.1.2 python-MarkupSafe-0.23-37.14 python-psutil-5.0.0-78.1 python-tornado-4.4.2-6.4 python-m2crypto-0.21.1-2.4.1 zypp-plugin-python-0.5-1.5 python-gnome-menus-2.28.0.1-1.1.213 libpython2_6-1_0-32bit-2.6.9-39.1 python-certifi-2016.2.28-10.5 python-msgpack-python-0.4.8-45.2 python-simplejson-3.8.2-57.1 python-PyYAML-3.12-29.3 python-paramiko-1.16.0-39.1 python-devel-2.6.9-39.1 python-argparse-1.2.1-2.5.65 yast2-python-bindings-2.17.4-1.32.115 python-base-2.6.9-39.1 python-demo-2.6.9-39.1 python-requests-2.0.1-0.9.37 rpm-python-4.4.2.3-37.63.64.2 python-backports_abc-0.4-2.1 python-greenlet-0.4.10-26.3 python-six-1.10.0-55.1 python-Jinja2-2.8-71.6 python-pyzmq-15.2.0-68.45 libxml2-python-2.7.6-0.31.1 python-gobject2-2.20.0-1.1.56 python-satsolver-0.44.5-0.5.194 python-gnome-2.22.0-67.32 libpython2_6-1_0-2.6.9-39.1 python-ordereddict-1.1-0.7.31 python-backports.ssl_match_hostname-3.5.0.1-7.6 python-pycrypto-2.6.1-41.1 python-numeric-24.2-195.17 python-orbit-2.14.3-137.26 python-cairo-1.6.4-1.26 python-2.6.9-39.1 python-ecdsa-0.13-14.1 python-py-1.4.31-51.3 python-singledispatch-3.4.0.3-8.10

akumacxd commented 7 years ago

is it about dmidecode?

Master001:/srv/salt # which dmidecode /usr/sbin/dmidecode Master001:/srv/salt # rpm -qf /usr/sbin/dmidecode pmtools-20071116-44.35.1

Ch3LL commented 7 years ago

@akumacxd this usually is due to running salt as a different use or wrong permissions on a directory. It is stating any grains that rely on dmidecode will not be processed due to permission errors on the box's end, not salts. Also by chance are you running in a docker container? If so there is this issue: https://github.com/saltstack/salt/issues/31266 that might help you out.

akumacxd commented 7 years ago

@Ch3LL Firstly I am not runing in a docker cotainer

Then according to the following steps: (1)Using the root user to Install Master minion in SUSE11SP4 zypper addrepo http://download.opensuse.org/repositories/systemsmanagement:/saltstack/SLE_11_SP4/systemsmanagement:saltstack.repo zypper refresh zypper install salt salt-minion salt-master

(2)Start Service:/etc/init.d/master start (3)tailf /var/log/salt/master the following warning is printed: 2017-02-05 20:51:48,811 [salt.loaded.int.grains.core ][WARNING ][10593] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate. 2017-02-05 20:51:48,848 [salt.loaded.int.grains.core ][WARNING ][10607] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.

root user should not have permission problem.

Ch3LL commented 7 years ago

@akumacxd oh I guess i should have read the title a little more clearer. you do specify that you are using the root user.

I do not have access to a sles VM right now. If you could run salt-call --local cmd.run_all then echo $? Looks like the code is looking for the retcode from that command.

akumacxd commented 7 years ago

@Ch3LL Thank you for your kind reply,The following is according to your command output:

Master001:~ # salt-call --local cmd.run_all

Passed invalid arguments: run_all() takes at least 1 non-keyword argument (0 given).

Usage:

Execute the passed command and return a dict of return data

:param str cmd: The command to run. ex: 'ls -lart /home'

:param str cwd: The current working directory to execute the command in,
  defaults to /root

:param str stdin: A string of standard input can be specified for the
  command to be run using the ``stdin`` parameter. This can be useful in cases
  where sensitive information must be read from standard input.:

:param str runas: User to run script as. If running on a Windows minion you
  must also pass a password

:param str password: Windows only. Required when specifying ``runas``. This
  parameter will be ignored on non-Windows platforms.

  .. versionadded:: 2016.3.0

:param str shell: Shell to execute under. Defaults to the system default
  shell.

:param bool python_shell: If False, let python handle the positional
  arguments. Set to True to use shell features, such as pipes or redirection

:param list env: A list of environment variables to be set prior to
  execution.

    Example:

    .. code-block:: yaml

        salt://scripts/foo.sh:
          cmd.script:
            - env:
              - BATCH: 'yes'

    .. warning::

        The above illustrates a common PyYAML pitfall, that **yes**,
        **no**, **on**, **off**, **true**, and **false** are all loaded as
        boolean ``True`` and ``False`` values, and must be enclosed in
        quotes to be used as strings. More info on this (and other) PyYAML
        idiosyncrasies can be found :doc:`here
        </topics/troubleshooting/yaml_idiosyncrasies>`.

    Variables as values are not evaluated. So $PATH in the following
    example is a literal '$PATH':

    .. code-block:: yaml

        salt://scripts/bar.sh:
          cmd.script:
            - env: "PATH=/some/path:$PATH"

    One can still use the existing $PATH by using a bit of Jinja:

    .. code-block:: yaml

        {% set current_path = salt['environ.get']('PATH', '/bin:/usr/bin') %}

        mycommand:
          cmd.run:
            - name: ls -l /
            - env:
              - PATH: {{ [current_path, '/my/special/bin']|join(':') }}

:param bool clean_env: Attempt to clean out all other shell environment
  variables and set only those provided in the 'env' argument to this
  function.

:param str template: If this setting is applied then the named templating
  engine will be used to render the downloaded file. Currently jinja, mako,
  and wempy are supported

:param bool rstrip: Strip all whitespace off the end of output before it is
  returned.

:param str umask: The umask (in octal) to use when running the command.

:param str output_loglevel: Control the loglevel at which the output from
  the command is logged. Note that the command being run will still be logged
  (loglevel: DEBUG) regardless, unless ``quiet`` is used for this value.

:param int timeout: A timeout in seconds for the executed process to return.

:param bool use_vt: Use VT utils (saltstack) to stream the command output
  more interactively to the console and the logs. This is experimental.

.. note::
  ``env`` represents the environment variables for the command, and
  should be formatted as a dict, or a YAML string which resolves to a dict.

redirect_stderr : False
    If set to ``True``, then stderr will be redirected to stdout. This is
    helpful for cases where obtaining both the retcode and output is
    desired, but it is not desired to have the output separated into both
    stdout and stderr.

    .. versionadded:: 2015.8.2

CLI Example:

.. code-block:: bash

    salt '*' cmd.run_all "ls -l | awk '/foo/{print \$2}'"

The template arg can be set to 'jinja' or another supported template
engine to render the command arguments before execution.
For example:

.. code-block:: bash

    salt '*' cmd.run_all template=jinja "ls -l /tmp/{{grains.id}} | awk '/foo/{print \$2}'"

A string of standard input can be specified for the command to be run using
the ``stdin`` parameter. This can be useful in cases where sensitive
information must be read from standard input.:

.. code-block:: bash

    salt '*' cmd.run_all "grep f" stdin='one\ntwo\nthree\nfour\nfive\n'

Master001:~ # echo $? 1

Ch3LL commented 7 years ago

oh man i am so sorry i mean salt-call --local cmd.run_all dmidecode. then echo $?

akumacxd commented 7 years ago
Master001:~ # salt-call --local cmd.run_all dmidecode
local:
    ----------
    pid:
        86741
    retcode:
        0
    stderr:
    stdout:
        # dmidecode 2.12
        SMBIOS 2.7 present.
        620 structures occupying 29188 bytes.
        Table at 0x000E0010.

        Handle 0x0000, DMI type 0, 24 bytes
        BIOS Information
                Vendor: Phoenix Technologies LTD
                Version: 6.00
                Release Date: 07/02/2015
                Address: 0xEA5E0
                Runtime Size: 88608 bytes
                ROM Size: 64 kB
                Characteristics:
                        ISA is supported
                        PCI is supported
                        PC Card (PCMCIA) is supported
                        PNP is supported
                        APM is supported
                        BIOS is upgradeable
                        BIOS shadowing is allowed
                        ESCD support is available
                        Boot from CD is supported
                        Selectable boot is supported
                        EDD is supported
                        Print screen service is supported (int 5h)
                        8042 keyboard services are supported (int 9h)
                        Serial services are supported (int 14h)
                        Printer services are supported (int 17h)
                        CGA/mono video services are supported (int 10h)
                        ACPI is supported
                        Smart battery is supported
                        BIOS boot specification is supported
                        Function key-initiated network boot is supported
                        Targeted content distribution is supported
                BIOS Revision: 4.6
                Firmware Revision: 0.0

        Handle 0x0001, DMI type 1, 27 bytes
        System Information
                Manufacturer: VMware, Inc.
                Product Name: VMware Virtual Platform
                Version: None
                Serial Number: VMware-56 4d 7f 23 32 f0 a6 c2-cc 43 2d c1 26 ab b5 72
                UUID: 564D7F23-32F0-A6C2-CC43-2DC126ABB572
                Wake-up Type: Power Switch
                SKU Number: Not Specified
                Family: Not Specified

        Handle 0x0002, DMI type 2, 15 bytes
        Base Board Information
                Manufacturer: Intel Corporation
                Product Name: 440BX Desktop Reference Platform
                Version: None
                Serial Number: None
                Asset Tag: Not Specified
                Features: None
                Location In Chassis: Not Specified
                Chassis Handle: 0x0000
                Type: Unknown
                Contained Object Handles: 0

        Handle 0x0003, DMI type 3, 21 bytes
        Chassis Information
                Manufacturer: No Enclosure
                Type: Other
                Lock: Not Present
                Version: N/A
                Serial Number: None
                Asset Tag: No Asset Tag
                Boot-up State: Safe
                Power Supply State: Safe
                Thermal State: Safe
                Security Status: None
Master001:~ # echo $?
0
Ch3LL commented 7 years ago

@akumacxd that seems to be correct and what I would expect in order for it not to log that error. Let me ask anyone around here if i can get access to a sles machine so i can track this down more for you and see if i can replicate it.

akumacxd commented 7 years ago

@Ch3LL Thanks You means that you want to access our sles machine? I think it's OK, just VM machine in my laptop. How to access my machine? VNC ? TeamViewer ? When do you access my machine ? we have time difference (+8 )

Ch3LL commented 7 years ago

Sorry I just got access to an sles iso today. So wont need access to you VM. Thanks though :) I'll install it and have an update for tomorrow to state whether I was able to replicate it or not. Thanks

akumacxd commented 7 years ago

@Ch3LL i know what's going on, Change the following configuration file vim /etc/satl/master

# the job cache, which must be deleted if this user is changed. If the
# modified files cause conflicts, set verify_env to False.
user: root
#user: salt
#syndic_user: salt

The default is to use: vim /etc/satl/master

user: salt
syndic_user: salt

I compared the red hat configuration file,found different that!!

Ch3LL commented 7 years ago

Oh so you are running salt as a different user then? That would definitely make sense as to why you are getting this error then.

You are stating that these were the default configurations which should not be the case. How did you install salt on this sles box?

akumacxd commented 7 years ago

according to the following steps:

For SLE 11 SP4 run the following as root: zypper addrepo http://download.opensuse.org/repositories/systemsmanagement:/saltstack/SLE_11_SP4/systemsmanagement:saltstack.repo zypper refresh zypper install salt salt-minion salt-master

I didn't change any configuration , start salt service ; If you doubt, you can install it again on suse11sp4, you will find different

The main configuration file by default is: user: salt syndic_user: salt

F30 commented 7 years ago

This warning is common when running Salt as non-root user (see #2494, Thread, #5249, #39184).

It does not really indicate a major problem, but I'm trying to address it through PR #39504.

renzhengeek commented 7 years ago

I also get this warning on openSUSE 42.3 as root user. What I do is only installation and start salt-master service:

a19:~ # cat /etc/issue
Welcome to openSUSE Leap 42.3 - Kernel \r (\l).

# systemctl status salt-master.service 
● salt-master.service - The Salt Master Server
   Loaded: loaded (/usr/lib/systemd/system/salt-master.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-08-30 13:18:31 CST; 9s ago
 Main PID: 30485 (salt-master)
    Tasks: 41
   CGroup: /system.slice/salt-master.service
           ├─30485 /usr/bin/python /usr/bin/salt-master
           ├─30496 /usr/bin/python /usr/bin/salt-master
           ├─30500 /usr/bin/python /usr/bin/salt-master
           ├─30501 /usr/bin/python /usr/bin/salt-master
           ├─30504 /usr/bin/python /usr/bin/salt-master
           ├─30505 /usr/bin/python /usr/bin/salt-master
           ├─30506 /usr/bin/python /usr/bin/salt-master
           ├─30507 /usr/bin/python /usr/bin/salt-master
           ├─30508 /usr/bin/python /usr/bin/salt-master
           ├─30515 /usr/bin/python /usr/bin/salt-master
           ├─30516 /usr/bin/python /usr/bin/salt-master
           ├─30517 /usr/bin/python /usr/bin/salt-master
           └─30518 /usr/bin/python /usr/bin/salt-master

Aug 30 13:18:32 a19 salt-master[30485]: [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
Aug 30 13:18:32 a19 salt-master[30485]: [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
Aug 30 13:18:32 a19 salt-master[30485]: [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.
Aug 30 13:18:33 a19 salt-master[30485]: [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.

Don't know how to work around this warning, or just leave it alone?

Ch3LL commented 7 years ago

as @F30 described this is not harmful. This means you are running salt as a different user other then root. Check your config for user: <username> possibly.

There is also a PR to improve this error handling to only log as info instead of warning here https://github.com/saltstack/salt/pull/39504

what version of salt are you using?

renzhengeek commented 7 years ago

as @F30 described this is not harmful. This means you are running salt as a different user other then >root. Check your config for user: possibly.

But, I do start salt-master.service with root user. The config in /etc/salt/master:

user: salt
syndic_user: salt

a19:~ # salt --version salt 2016.11.4 (Carbon)

For me, it's enough to know it doesn't matter. Thanks a lot.

F30 commented 7 years ago

@renzhengeek It doesn't seem to matter as which user you start it, if you have such a line in your config Salt is gonna run as root and throw that warning.

Ch3LL commented 7 years ago

Yes as @F30 states it will run as that user. If you were to check your process list you would see it running as salt. I did find out that suse does manage those packages and they purposefully are setting the salt user on the install of the packages. Closing this as it is resolved.

mitar commented 6 years ago

I see the same warning, I am running salt-ssh as non-root (it connects to the machine as non-root), but I have sudo: True configured. So everything else works, because salt uses sudo, but maybe the issue is that it does not use sudo for dmidecode?

I am using salt==2016.11.1.

hemna commented 5 years ago

I am seeing this as well. the /etc/salt/master has user of salt as installed by the rpm.

bluemalkin commented 5 years ago

Hi I am seeing this [INFO ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.

I'm running salt salt 2019.2.0 (Fluorine) in Docker. user: root in master conf.

I do not want to run it as a privileged container.

Is there a way to entirely suppress the log line which pollutes the logging ?

Thanks

tvb commented 1 year ago

@bluemalkin lets link up with this one too