Commit graph

114400 commits

Author SHA1 Message Date
jeanluc
46339d9e79 Fix vault ext pillar return data for KV v2 2022-09-26 13:42:12 -06:00
jeanluc
468ebed676 Add vault pillar unit test 2022-09-26 13:42:12 -06:00
Jasper Koolhaas
531dfd4fa1 rollback salt.7 manpage changes 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
99598bb603 rollback salt.7 manpage changes 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
09f62b197c added ext_pillar docstring 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
06a3a544a5 lint fixes 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
d7254d6b23 lint fixes 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
9cfe61183d lint fixes 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
1317402914 rm jinja test 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
4116b1c15b added stack pillar unit test 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
0102a145c7 updates to /docs/man/salt.7 and /changelog 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
34f33930de mv pillarenv -> saltenv in stack example 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
09e6438a27 fix codingstyle issue 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
b8fb42f794 coding style cleanup 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
27db682d49 fix empty yaml file 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
45f56e6d84 example in docstring 2022-09-26 12:57:53 -06:00
Jasper Koolhaas
a3d7990eb2 __env__ substitution ubsude stack pillar and better parsing error handling 2022-09-26 12:57:53 -06:00
Benjamin Drung
27353ab10a grains: Add test case for _linux_lsb_distrib_data()
The test cases for `os_data` do not cover the case that `lsb_release` is
imported successfully. So add a test case for that.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-26 12:55:23 -06:00
Benjamin Drung
862ccf886b grains: Set os grain in each branch in os_data()
In `os_data()` only the kernel branch for `SunOS` might not set the `os`
grain. To make the code easier to read, ensure that `os` is set in each
branch in `os_data()`.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-26 12:55:23 -06:00
Benjamin Drung
8606002feb grains: Set os_family in each branch in os_data()
To make the code easier to read, set `os_family` in each branch in
`os_data()`. Most branches have an hard-coded OS family and can be
dropped from `_OS_FAMILY_MAP`. The dictionary `_OS_FAMILY_MAP` is now
only used for deriving the OS family of Linux.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-26 12:55:23 -06:00
Benjamin Drung
3e49a67aab grains: Move fetching LSB grains into separate function
Move fetching `lsb_distrib_*` grains into separate function
`_linux_lsb_distrib_data` to make `_linux_distribution_data` shorter.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-26 12:55:23 -06:00
Benjamin Drung
b6cefabbd5 grains: Refactor os_data to one single "case" state
`os_data` has a case-like statement to differentiate the different
operating systems, but this is split into two parts.

To make the code more readable, combine all case-like statement in
`os_data` to use one long if-elif chain.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-26 12:55:23 -06:00
Benjamin Drung
a9195ab77b grains: Split os_data into smaller functions
The `os_data` function is huge (531 lines for one function is too long)
and also deeply nested (8 levels deep). That make reading, modifying,
and testing this function harder.

Split `os_data` into smaller functions to a readable 167 lines with only
a nesting level of three.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
2022-09-26 12:55:23 -06:00
Caleb Beard
8696b2859a
migrate pillar unit tests to pytest (#62745) 2022-09-25 17:28:42 -07:00
Shane Lee
b13e585d30
Migrate LGPO tests to pytest (#62731)
* Migrate LGPO tests to pytest

* Fix pre-commit test failures

* Fix lint failure

* Fix some failing tests

* Fix failing state test

* Move unlink into fixtures

* Whoops, missed one...

* Fix pre-commit

* Fix some lint
2022-09-22 21:32:52 -07:00
Benjamin Drung
3325f7dd01
linux_sysctl: Fix replacing spaces by tabs and fix parsing of sysctl.conf files (#61452)
* test_linux_sysctl: Reduce indentation level

Reduce indentation level to improve readability.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>

* test_linux_sysctl: Fix test_persist_no_conf_failure

`test_persist_no_conf_failure` has different behaviour depending on the
operating system it is executed on. Mock all system calls and let it
fail in the first try to write the sysctl configuration file.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>

* linux_sysctl: Pass parameters as list to cmd.run

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>

* linux_sysctl.show: Fix parsing of sysctl.conf files

The lines in sysctl.conf files can contain leading and trailing spaces.
The equal sign (that separates the key and value) might have zero to
multiple white spaces. Valid example:

```
kernel.core_pattern = |/usr/share/kdump-tools/dump-core %p %s %t %e
 # Stop low-level messages on console = less logging
 kernel.printk  = 3 4 1 3

net.ipv4.ip_forward=1
```

`sysctl.show` currently has two issues:
* all values contain a trailing newline
* Comments with leading spaces and equal sign in them are not skipped

Address both issues and simplify the code and cover them with unit tests.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>

* linux_sysctl.present: Fix replacing spaces by tabs

`salt/modules/linux_sysctl.py` tries to be smart in `persist()` and
replaces spaces by tabs, which will be correct for keys like
`net.ipv4.tcp_rmem` but not for `kernel.core_pattern`.

So only sanitize the values for comparison, but not for persisting them
in the configuration file.

Bug: https://github.com/saltstack/salt/issues/40054
Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>

* linux_sysctl: Drop unreachable code

The check `if "=" not in line` already ensures that the split by `=`
will return two elements.

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>

* fixing failing tests

* need to mock which in test_assign_success

Signed-off-by: Benjamin Drung <benjamin.drung@ionos.com>
Co-authored-by: Benjamin Drung <benjamin.drung@ionos.com>
Co-authored-by: Gareth J. Greenaway <gareth@saltstack.com>
2022-09-22 21:31:59 -07:00
MKLeb
3cd9642236 fix pytest skip marker 2022-09-22 16:06:11 -07:00
MKLeb
d116107432 fix failing windows test 2022-09-22 16:06:11 -07:00
MKLeb
5369d5843c migrate fileserver unit tests to pytest 2022-09-22 16:06:11 -07:00
Megan Wilhite
863df6de7e Update mako requirement to 1.2.2 2022-09-22 15:21:26 -07:00
Gareth J. Greenaway
5961eb9435 adding changelog. updating tests to reflect changes. 2022-09-22 14:22:36 -07:00
Daan van Gorkum
5c77b2beaa Use return code in iptables --check to verify is rule exists (salt/modules/iptables.py)
Since the check option in iptables was introduced (https://git.netfilter.org/iptables/commit/?id=d59b9db031abee37a9aa9776662dd15370faabf4) it's safe to use the return code to check if a rule exists or not.
Before this commit salt would check if the return from `iptables --check` was empty, if it was it assumed the rule was there. Since Debian Bullseye `iptables --check` return the active rule breaking `iptables.checks` module.

This commit changes this to return True or False based on the `cmd.run` returncode.

Signed-off-by: Daan van Gorkum <djvg@djvg.net>
Fixes: 60467
2022-09-22 14:22:36 -07:00
Gareth J. Greenaway
f65cf0259a Update http.py
Removing reference to six.
2022-09-22 13:35:31 -07:00
Megan Wilhite
f3c251e1d7 run pre-commit 2022-09-22 13:35:31 -07:00
Megan Wilhite
dfa9f7d309 Add changelog for 62595 2022-09-22 13:35:31 -07:00
Jonas Maurus
e6677766bc Port 52383 to master branch 2022-09-22 13:35:31 -07:00
Timothee "TTimo" Besset
6524733df0 Update runner.py
Typos in the documentation
2022-09-22 14:29:53 -06:00
Megan Wilhite
b7a9497614
Merge pull request #62510 from s0undt3ch/hotfix/payload
Remove skip added on `freeze`. A litle refactor and timeouts relax.
2022-09-22 13:06:00 -06:00
Gareth J. Greenaway
427680936f Adding changelog. 2022-09-22 12:02:10 -07:00
Gareth J. Greenaway
66c348da2c Running pre-commit. Updating tests to reflect changes. 2022-09-22 12:02:10 -07:00
Gareth J. Greenaway
ce1de2d7ad Update puppet.py
Fixing lint issues.
2022-09-22 12:02:10 -07:00
Eric Cook
0c1d54bc49 fix puppet.py for non-aio installs 2022-09-22 12:02:10 -07:00
James Howe
6cf47ba1a1 Fix syntax in sdb.get_or_set_hash examples 2022-09-22 12:25:55 -06:00
James Howe
f45b414710 Ensure CLI example uses correct quoting
See e.g. #62719
2022-09-22 12:23:42 -06:00
Megan Wilhite
64e2d5450e
Merge pull request #62735 from Ch3LL/1fix_changelog
Add back 62678 changelog
2022-09-22 11:52:02 -06:00
Megan Wilhite
e5097d2740
Add back 62678 changelog 2022-09-22 11:30:14 -06:00
Megan Wilhite
9525881a05
Merge pull request #62728 from cro/reqserver_info_not_error
Change log.error to log.info
2022-09-22 11:28:02 -06:00
Megan Wilhite
f29ffc85f2
Fix changelog file to fixed extension and correct number 2022-09-22 11:20:22 -06:00
Megan Wilhite
981d861c2f
Merge pull request #62295 from nicholasmhughes/fix-matcher-slowness
Fix match function call slowness at scale
2022-09-22 09:44:15 -06:00
Carlos Álvaro
3b2519e7c3 Fix test_list_pkgs_homebrew_cask_pakages 2022-09-22 09:31:48 -06:00