salt/tests/pytests/unit
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
..
_logging Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
auth Move remaining auth unit test to pytest 2022-09-19 12:52:33 -06:00
beacons Merge tag 'v3005.1' into merge-forward/3005.1 2022-10-04 20:52:23 -04:00
cache Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
cli move cli unit tests to pytest 2022-09-19 13:00:25 -06:00
client Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
cloud Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
config migrate config unit tests to pytest 2022-08-31 15:53:57 -04:00
daemons move daemons unit tests to pytest 2022-09-19 13:14:25 -06:00
engines Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
executors move executors tests to pytest 2022-09-19 13:08:32 -06:00
fileserver fix pytest skip marker 2022-09-22 16:06:11 -07:00
grains Fix OS grain inconsistencies if lsb-release is installed or not 2022-11-30 13:12:14 -07:00
loader loader: Add __opts__ to pack if not already present 2022-11-07 13:35:04 -07:00
log_handlers Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
matchers move matchers unit tests to pytest 2022-09-21 11:35:34 -06:00
modules Replace lsb_distrib_codename by oscodename 2022-11-30 13:12:14 -07:00
netapi Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
output Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
pillar Merge pull request #62674 from lkubb/vault-pillar-templating 2022-11-29 13:12:38 -07:00
proxy Updating ssh_sample proxy to aid in testing. Adding unit tests for ssh_sample proxy. 2022-10-27 14:58:32 -07:00
renderers Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
returners Add testcases for mongo ext_pillar and returner 2022-11-18 12:53:02 -07:00
roster add some tests 2022-10-10 16:48:48 -04:00
runners Merge branch 'master' into vault-pillar-templating 2022-10-13 12:14:08 +02:00
sdb move sdb unit tests to pytest 2022-10-10 17:41:14 -04:00
serializers renaming envfile serializer to keyvalue 2022-11-08 12:52:59 -07:00
spm Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
state Merge branch 'master' into add-global-state-conditions 2022-11-21 09:12:02 -05:00
states Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
tokens migrate tokens unit tests to pytest 2022-11-04 16:26:42 -04:00
tops migrate tops unit tests to pytest 2022-11-04 16:30:30 -04:00
transport Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
utils Merge pull request #62674 from lkubb/vault-pillar-templating 2022-11-29 13:12:38 -07:00
__init__.py Pyupgrade and drop six 2021-07-06 09:04:28 -04:00
conftest.py Add master_opts fixture under tests/pytests/unit 2022-11-18 12:36:51 -07:00
test_beacons.py Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
test_client.py Use the minion_opts and master_opts fixtures instead. 2022-11-18 12:36:51 -07:00
test_config.py Add changelog 2022-04-19 16:44:43 -07:00
test_crypt.py Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
test_defaults.py Fix payload and defaults (#62458) 2022-08-17 18:24:35 -06:00
test_ext_importers.py Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
test_master.py do what the ci thing is yelling at me for? 2022-11-07 12:12:16 -05:00
test_minion.py minion_opts fixture is now available for all tests under tests/pytests/unit 2022-11-18 12:36:51 -07:00
test_payload.py Fix payload and defaults (#62458) 2022-08-17 18:24:35 -06:00
test_pytest_pass_fail.py Pyupgrade and drop six 2021-07-06 09:04:28 -04:00
test_syspaths.py Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
test_version.py add .0 back to the version 2022-09-28 13:11:41 -06:00