Software to automate the management and configuration of infrastructure and applications at scale.
Find a file
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
.github Updated per review comments 2022-09-15 10:21:44 -06:00
.pre-commit-hooks Merge 3003.3 into master (#60924) 2021-09-22 17:42:38 -07:00
changelog linux_sysctl: Fix replacing spaces by tabs and fix parsing of sysctl.conf files (#61452) 2022-09-22 21:31:59 -07:00
cicd Remove Debian 9: EoL 2022-07-19 06:35:00 -06:00
conf fixes saltstack/salt#61708 add grains_refresh_pre_exec option for minions 2022-03-08 15:33:13 -05:00
doc Give the actual .netrc path 2022-09-21 12:01:13 -06:00
pkg Make sure sudo is launche with -E 2022-08-17 11:22:46 -06:00
requirements Update mako requirement to 1.2.2 2022-09-22 15:21:26 -07:00
rfcs Port #50553 to master 2020-10-07 16:09:36 -07:00
salt linux_sysctl: Fix replacing spaces by tabs and fix parsing of sysctl.conf files (#61452) 2022-09-22 21:31:59 -07:00
scripts Update zyppnotify 2022-05-24 16:11:08 -04:00
tasks Update to isort 5.10.1 2022-08-01 12:49:16 -06:00
templates Pyupgrade and drop six 2021-07-06 09:04:28 -04:00
tests linux_sysctl: Fix replacing spaces by tabs and fix parsing of sysctl.conf files (#61452) 2022-09-22 21:31:59 -07:00
.bandit Address Bandit's B602(subprocess_popen_with_shell_equals_true) on the test suite 2021-03-03 06:21:53 -05:00
.codeclimate.yml
.codecov.yml A few additional replacements for `SaltStack, Inc` 2022-04-06 15:35:31 -04:00
.coveragerc Teach coverage a bit more about salt paths. 2020-08-11 10:21:27 -07:00
.editorconfig
.git-blame-ignore-revs Update ignored revisions for git-blame 2021-02-22 14:12:11 -05:00
.gitattributes
.gitignore update .gitignore 2021-07-23 13:06:52 -07:00
.gitlab-ci.yml Revert "Add ShiftLeft Scan to the pipeline" 2020-07-14 15:25:04 -07:00
.mention-bot
.pre-commit-config.yaml Merge freeze into master (#62438) 2022-08-08 11:27:10 -06:00
.pylintrc Updates required for `pytest-salt-factories>=1.0.0rc16` 2022-06-02 07:05:09 -06:00
.rstcheck.cfg Start checking rst files at pre-commit level with rstcheck 2020-10-13 13:53:16 -07:00
AUTHORS Updating email references from nmadhok@clemson.edu to nmadhok@g.clemson.edu 2021-02-16 11:15:39 -05:00
CHANGELOG.md Update docs with new change for 3005 release 2022-08-22 13:43:55 -06:00
CODE_OF_CONDUCT.md Updating to v2.0 of contributor covenant 2020-09-30 13:28:39 -07:00
CONTRIBUTING.rst Add imagemagick prereq (#60771) 2021-08-27 10:10:03 -07:00
DEPENDENCIES.md Add dates of copyright to dependencies 2020-09-04 10:14:56 -07:00
Gemfile Use main branch for kitchen-docker project 2022-02-01 11:00:41 +00:00
kitchen.yml Change to https:// URL 2022-01-11 12:44:59 -08:00
LICENSE A more legal approach 2022-04-06 15:35:31 -04:00
MANIFEST.in Test fixes when running with the onedir build 2022-08-29 13:24:21 -07:00
noxfile.py Add nox sessions for coverage reporting 2022-08-28 19:09:38 +01:00
pyproject.toml Merge 3003.3 into master (#60924) 2021-09-22 17:42:38 -07:00
pytest.ini Upgrade to PyTest 5.x 2020-05-22 09:17:36 -07:00
README.rst Update documentation to avoid reference to freenode. 2021-06-09 14:11:47 -07:00
run.py Merge tag 'v3005' into merge-forward/3005 2022-08-30 20:06:17 -04:00
SECURITY.md Updating links to point to master branch docs 2021-02-23 09:12:30 +00:00
setup.cfg Use root as user:owner in sdist generated tars 2021-05-25 16:00:21 -07:00
setup.py Merge freeze forward into master (#62403) 2022-08-01 17:44:17 -07:00
SUPPORT.rst change docs.saltstack.com to docs.saltproject.io everywhere 2021-09-09 15:30:03 -07:00

Salt Project License: Apache v2.0

PyPi Package Downloads

PyPi Package Downloads

Salt Project Slack Community

Salt Project Twitch Channel

Salt Project subreddit

Follow SaltStack on Twitter

https://gitlab.com/saltstack/open/salt-branding-guide/-/raw/master/logos/SaltProject_altlogo_teal.png?inline=true

Salt is the worlds fastest, most intelligent and scalable automation engine.

About Salt

Built on python, Salt uses simple and human-readable YAML combined with event-driven automation to deploy and configure complex IT systems. In addition to leveling-up vRealize Automation SaltStack Config, Salt can be found under the hood of products from Juniper, Cisco, Cloudflare, Nutanix, SUSE, and Tieto, to name a few.

About SaltStack

SaltStack was acquired by VMware in 2020. Salt Project remains an open source ecosystem that VMware supports and contributes to.

Download Salt

Salt is tested and packaged to run on CentOS, Debian, RHEL, Ubuntu, MacOS, Windows, and more. Download Salt and get started now.

Salt Project Documentation

Installation instructions, getting started guides, in-depth API documentation, and contributing to Salt.

Security Advisories

Keep an eye on the Salt Project Security Announcements landing page. Salt Project recommends subscribing to the Salt Project Security RSS feed to receive notification when new information is available regarding security announcements.

Other channels to receive security announcements include the Salt Community mailing list and the Salt Project Community Slack.

Responsibly Reporting Security Vulnerabilities

When reporting security vulnerabilities for Salt or other SaltStack projects, refer to the SECURITY.md file found in this repository.

Engage the Salt Project and The Community

Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Project Community Events Calendar on the main https://saltproject.io website.

If you have additional questions, email us at saltproject@vmware.com or reach out directly to the Community Manager, Janae Andrus via Slack. Wed be glad to have you join our community!

License

Salt is licensed under the Apache 2.0 license. Please see the LICENSE file for the full text of the Apache license, followed by a full summary of the licensing used by external modules.

A complete list of attributions and dependencies can be found here: salt/DEPENDENCIES.md