Commit graph

1195 commits

Author SHA1 Message Date
Daniel A. Wozniak
c695e0bcff Merge branch '3006.x' into merge/3007.x/3006.x 2025-03-07 15:05:05 -07:00
Georg Pfuetzenreuter
24a58e8211 Set virtual grain in Podman systemd container
Some checks failed
CI / Prepare Workflow Run (push) Has been cancelled
CI / Pre-Commit (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / NSIS Tests (push) Has been cancelled
CI / Prepare Release: (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / Build Source Tarball (push) Has been cancelled
CI / Build Onedir Dependencies (push) Has been cancelled
CI / Build Salt Onedir (push) Has been cancelled
CI / Build Packages (push) Has been cancelled
CI / CI Deps (push) Has been cancelled
CI / Test Package (push) Has been cancelled
CI / Test Salt (push) Has been cancelled
CI / Combine Code Coverage (push) Has been cancelled
CI / Set the Pipeline Exit Status (push) Has been cancelled
Correctly handle the systemd-detect-virt output to identify a Podman
container running systemd as what it is instead of as a physical machine.

Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
2025-02-26 14:04:01 -07:00
Daniel A. Wozniak
d625eaeea8 Merge branch '3006.x' into merge/3007.x/3006.x-last-merge 2025-02-14 01:23:02 -07:00
Tom Doherty
5a097a50be Recognise newer AMD GPU devices 2025-01-31 11:30:24 -07:00
Daniel A. Wozniak
19dfa41bb9 Merge remote-tracking branch 'saltstack/3006.x' into merge/3007.x/3006.x 2024-09-26 15:01:16 -07:00
vzhestkov
47e412cc5c Better handling output of systemctl --version 2024-09-25 02:28:51 -07:00
Daniel A. Wozniak
6b3418fe0b Merge remote-tracking branch 'saltstack/3006.x' into merge/3007.x/3006.x 2024-09-20 14:20:13 -07:00
Daniel A. Wozniak
468b26e918 initial work on log once option 2024-09-13 14:24:05 -07:00
Daniel A. Wozniak
8dd2e3473c Merge branch '3006.x' into merge/3007.x/3006.x 2024-08-26 19:26:17 -07:00
Gareth J. Greenaway
852bf0004a Ensure Manjaro ARM reports the correct os_family of Arch. 2024-08-12 12:41:36 -07:00
Daniel A. Wozniak
60cc8dbce8 Merge forward 3006.x into 3007.x 2024-06-21 23:53:49 -07:00
David Murphy
848c7ad5bf Moved get_machine_identifier to salt utils platfrom as per reviewers request 2024-06-03 12:24:11 -07:00
David Murphy
0de790cd28 Ensured use of get_machine_identifier from salt.utils.files for identifying a machine id 2024-06-03 12:24:11 -07:00
David Murphy
f98b7073cd Moved location for finding machine_id to salt utils files, and had grains import from there 2024-06-03 12:24:11 -07:00
Pedro Algarvio
b7630f3b08
Merge 3006.x into 3007.x 2024-02-29 14:25:24 +00:00
Pedro Algarvio
f4549113b1
Update pre-commit hook versions 2024-02-29 12:30:49 +00:00
Pedro Algarvio
03ad4c6337 Update code to be Py3.7+ to reduce merge forward conflicts 2024-02-29 10:16:58 +00:00
Pedro Algarvio
3dea2eb541 Update pre-commit hook versions 2024-02-29 10:16:58 +00:00
Pedro Algarvio
b9be2dec1b Update and remove obsolete pylint plugins 2024-02-27 08:07:04 +00:00
Pedro Algarvio
34ab8c732b
Merge 3006.x into 3007.x 2024-02-19 13:10:20 +00:00
Shane Lee
75db735867 Fix an issue with unresolved grains on Windows
Some WMI calls are returning empty, maybe something is corrupted
underneath. This will just return None for grains that can't be
collected using WMI.
2024-02-18 21:56:52 -07:00
Pedro Algarvio
e3ba31dc7a
Merge 3006.x into 3007.x 2023-12-14 11:32:20 +00:00
Gareth J. Greenaway
fb9a680f31 more test cases. 2023-12-12 15:29:12 -07:00
Gareth J. Greenaway
ac17af45e2 Adding tests for _bsd_memdata and excludes AIX and Solaris functions from coverage. 2023-12-12 15:29:12 -07:00
Pedro Algarvio
967d3015f6
Merge 3006.x into master 2023-12-05 18:10:58 +00:00
David Murphy
8e5d94b210 Further refinement of handling for verious OS's when lsb error 2023-11-29 21:40:06 +00:00
David Murphy
6502f4c730 Fix support for Mendel OS when lsb errors 2023-11-29 21:40:06 +00:00
David Murphy
fd990ea300 Revert to original setting grain oscodename from lsb_distrib_codename first 2023-11-29 21:40:06 +00:00
David Murphy
a4ef503982 Adjusted generation of oscodename and lsb_distrib_codename for grains. 2023-11-29 21:40:06 +00:00
David Murphy
cd279bd7d4 Fill out lsb_distrib_xxx grains (best guess) if lsb_release information unavailable 2023-11-29 21:40:06 +00:00
Pedro Algarvio
56ae8aa959 Handle the exception in salt/utils/platform.py instead
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-08-25 13:57:39 +00:00
Pedro Algarvio
717ae8089f Handle permissions access error when calling lsb_release with the salt user
```
[ERROR   ] [SaltMaster(id='master-NkEYGW')] An un-handled exception was caught by Salt's global exception handler:
CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 126.
Traceback (most recent call last):
  File "/usr/bin/salt-master", line 11, in <module>
    sys.exit(salt_master())
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/scripts.py", line 88, in salt_master
    master.start()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/cli/daemons.py", line 204, in start
    self.master.start()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/master.py", line 723, in start
    chan = salt.channel.server.PubServerChannel.factory(opts)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/channel/server.py", line 721, in factory
    return cls(opts, transport, presence_events=presence_events)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/channel/server.py", line 727, in __init__
    self.aes_funcs = salt.master.AESFuncs(self.opts)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/master.py", line 1233, in __init__
    self.mminion = salt.minion.MasterMinion(
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 974, in __init__
    self.opts = salt.config.mminion_config(
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/config/__init__.py", line 2332, in mminion_config
    opts["grains"] = salt.loader.grains(opts)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/__init__.py", line 1116, in grains
    ret = funcs[key]()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
    ret = self.loader.run(run_func, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
    return _func_or_method(*args, **kwargs)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/grains/core.py", line 2602, in os_data
    grains.update(_linux_distribution_data())
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/grains/core.py", line 2189, in _linux_distribution_data
    return _legacy_linux_distribution_data(grains, os_release, lsb_has_error)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/grains/core.py", line 2324, in _legacy_linux_distribution_data
    x.strip('"').strip("'") for x in _linux_distribution()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/platform.py", line 21, in linux_distribution
    return distro.name(), distro.version(best=True), distro.codename()
  File "/opt/saltstack/salt/lib/python3.10/site-packages/distro.py", line 287, in version
    return _distro.version(pretty, best)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/distro.py", line 741, in version
    self.lsb_release_attr('release'),
  File "/opt/saltstack/salt/lib/python3.10/site-packages/distro.py", line 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/opt/saltstack/salt/lib/python3.10/site-packages/distro.py", line 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/opt/saltstack/salt/lib/python3.10/site-packages/distro.py", line 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/opt/saltstack/salt/lib/python3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/opt/saltstack/salt/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 126.
```

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-08-25 13:57:39 +00:00
Pedro Algarvio
c463c94b8d Stop using the deprecated locale.getdefaultlocale() function
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-06-29 08:01:12 +01:00
Pedro Algarvio
aacdfc9b98 Stop using the deprecated locale.getdefaultlocale() function
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-06-28 18:06:15 +00:00
Pedro Algarvio
ad706711d3 Backport locale.getdefaultlocale() into Salt. It's getting removed in Py 3.13
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
2023-06-19 23:35:51 +01:00
cmcmarrow
36e150861c rebase 2023-03-21 21:42:08 +00:00
jeanluc
f9737ea019 Disable FQDNs grains on macOS by default 2023-02-02 13:45:19 -07:00
unman
d7173d448d Correct Parrot OS entry in grains _OS_Family_Map. Fix test. 2022-12-07 10:07:11 -07:00
unman
a0cfc990fe Include Parrot in grains _OS_Family_Map 2022-12-07 10:07:11 -07:00
nicholasmhughes
07b5980bf4 fixes saltstack/salt#63131 add boardname grain 2022-12-05 12:25:59 -07:00
Benjamin Drung
ca20bb320d Fix OS grain inconsistencies if lsb-release is installed or not
Most Linux distributions ship an os-release file by default. Some do not
ship lsb-release information, but they can be installed afterwards.
Installing/Removing lsb-release can lead to different OS grain values.

| OS               | grain      | without lsb-release              | with lsb-release |
|------------------|------------|----------------------------------|------------------|
| AlmaLinux 8      | oscodename | AlmaLinux 8.5 (Arctic Sphynx)    | ArcticSphynx     |
| Astra CE         | os         | Astra (Orel)                     | AstraLinuxCE     |
| Astra CE         | os_family  | Astra (Orel)                     | Debian           |
| Astra CE         | osfullname | Astra Linux (Orel)               | AstraLinuxCE     |
| Astra CE 2.12.40 | osfinger   | Astra Linux (Orel)-2             | AstraLinuxCE-2   |
| Debian           | osfullname | Debian GNU/Linux                 | Debian           |
| Mendel           | osfullname | Mendel GNU/Linux                 | Mendel           |
| Mendel 10        | osfinger   | Mendel GNU/Linux-10              | Mendel-10        |
| Mint             | osfullname | Linux Mint                       | Linuxmint        |
| Mint 20.3        | osfinger   | Linuxmint-20                     | Linux Mint-20    |
| Pop              | osfullname | Pop!_OS                          | Pop              |
| Pop 20.04        | osfinger   | Pop!_OS-20                       | Pop-20           |
| Rocky            | osfullname | Rocky Linux                      | Rocky            |
| Rocky 8          | osfinger   | Rocky Linux-8                    | Rocky-8          |
| Rocky 8          | oscodename | Rocky Linux 8.5 (Green Obsidian) | GreenObsidian    |

The current code that determines the OS grains on Linux is a mess: First
lsb-release is queried. If that fails, fall back to read os-release and
parse some `/etc/*-release` files. Then query `_linux_distribution` and
use a mixtures of those for the OS grains. `_linux_distribution` queries
the Python `distro` library. `distro` queries the os-release file,
lsb-release, and then `/etc/*-release`.

Rewrite the code that determines the OS grains on Linux. Solely rely on
the data provided by the os-release file. To not cause regressions, only
switch the distribution that has been tested. All other distributions
will use the legacy code (which was moved to
`_legacy_linux_distribution_data`).

The new code derives the `os_family` grain from the `ID_LIKE` field from
os-release (see https://github.com/saltstack/salt/issues/59061 for this
feature request). To enable this feature, the new code needs to be used
by default (and not just for selected distributions).

This commit introduces a few changes to the OS grains:

* AlmaLinux and Rocky Linux extract the codename from the `VERSION` field
  now instead of using the full `PRETTY_NAME`.
* Mendel uses now `Mendel GNU/Linux` as `osfullname` and correctly
  extracts the `osrelease` from `PRETTY_NAME`.
* Pop!_OS changes the `osfullname` from `Pop` to `Pop!_OS`.
* Astra Linux changes the `osfullname` from `AstraLinuxCE` to
  `Astra Linux (Orel)` and `AstraLinuxSE` to `Astra Linux (Smolensk)`
  respectively.

Fixes https://github.com/saltstack/salt/issues/61618
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-11-30 13:12:14 -07:00
Twangboy
0e41a5a4c4
Fix pre-commit 2022-10-27 21:12:29 -06:00
Twangboy
ea15af0493
Simplify regex 2022-10-27 21:12:29 -06:00
mxrss
d203d3ac5d
Update to RE #59611
* Fix bug and test case to deal with windows server core
2022-10-27 21:12:24 -06:00
Gareth J. Greenaway
e5c2262bbd
Removing manufacture grain which has been deprecated. 2022-10-19 18:50:58 -07:00
droogmic
173b56c6a7 Add EndeavourOS os_family
EndeavourOS is an Arch family OS.
2022-09-30 14:10:36 -07:00
Benjamin Drung
8d243d5020 Fix version part of osfinger on Pop!_OS
Pop!_OS uses the same version scheme than Ubuntu (YY.MM) and releases
every six month in April and October. Using only the year from the
version in the `osfinger` does not allow differentiating between 20.04
and 20.10. Both has the `osfinger` set to `Pop-20`.

So include the full version in the `osfinger` grain.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-30 13:48:51 -07:00
Benjamin Drung
dab8ea5b45 grains: Use platform.freedesktop_os_release
Python 3.10 introduced `platform.freedesktop_os_release` which does the
same as `_parse_os_release("/etc/os-release", "/usr/lib/os-release")`.

The parsing of the os-release files is nearly identical and differs only
slightly in the used regular expressions. In contrast to
`_parse_os_release`, `platform.freedesktop_os_release` caches the result
of the parsed os-release file.

Use `platform.freedesktop_os_release` when available. When salt drops
the support for Python < 3.10 (some time in the distant future),
`_parse_os_release` can be removed.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-30 12:52:40 -06:00
Benjamin Drung
19353a0762 grains: Align _parse_os_release with freedesktop_os_release
Change `_parse_os_release` to behave nearly identical to
`platform.freedesktop_os_release` from Python >= 3.10, if called with
("/etc/os-release", "/usr/lib/os-release").

There are no os-release files for Pop!_OS and therefore the test cases
would fail with an `OSError` now.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-30 12:52:40 -06:00
Victor Zhestkov
9741a85c8c Set virtual to Nitro for Amazon EC2 kvm instances 2022-09-29 12:24:40 -06:00