Compare commits

...

10 commits

Author SHA1 Message Date
ef44d44288 [logging] Mute return_output warning for explorers.
This adds a `warn_return_output` flag to
`cdist.exec.remote.Remote.(run_script|run|_run_command)`.

It defaults to `True` keeping current behaviour except when called from
`cdist.core.explorer.Explorer`.
This way debug logging is significantly cleaner.

Fixes #806
2020-04-28 13:35:48 +02:00
Darko Poljak
515992249d ++changelog 2020-04-27 22:55:57 +02:00
cd0c811d74 Merge branch 'evilham-explorers' into 'master'
[explorers] Improve *BSD support.

See merge request ungleich-public/cdist!869
2020-04-27 22:53:09 +02:00
965829e18a Merge branch 'evilham-cdist.cfg.skeleton' into 'master'
[docs] Improve cdist.cfg.skeleton

See merge request ungleich-public/cdist!868
2020-04-27 22:51:48 +02:00
bd66b6d948 Merge branch 'update_readme' into 'master'
update README

See merge request ungleich-public/cdist!870
2020-04-27 16:48:09 +02:00
b31e13eacf README: add bits about cdist-contrib 2020-04-27 16:30:52 +03:00
56a65518ab README: add participating section 2020-04-27 15:25:43 +03:00
0b3c417aef update README 2020-04-27 15:09:40 +03:00
678df1ec8a [explorers] Improve *BSD support.
cpu_cores and memory did lacked support for other BSDs.
2020-04-27 01:29:37 +02:00
fefc828780 [docs] Improve cdist.cfg.skeleton 2020-04-26 19:06:42 +02:00
8 changed files with 54 additions and 16 deletions

7
README
View file

@ -1,7 +0,0 @@
cdist
-----
cdist is a usable configuration management system.
For the web documentation have a look at https://www.cdi.st/
or at docs/src for reStructuredText manual.

31
README.md Normal file
View file

@ -0,0 +1,31 @@
# cdist
**cdist** is a usable configuration management system.
It adheres to the [**KISS principle**](https://en.wikipedia.org/wiki/KISS_principle)
and is being used in small up to enterprise grade environments.
For more information have a look at [**homepage**](https://cdi.st)
or at **``docs/src``** for manual in **reStructuredText** format.
## Contributing
Merge/Pull requests can be made in both
[upstream **GitLab**](https://code.ungleich.ch/ungleich-public/cdist/merge_requests)
(managed by [**ungleich**](https://ungleich.ch))
and [**GitHub** project](https://github.com/ungleich/cdist/pulls).
Issues can be made and other project management activites happen
[**only in GitLab**](https://code.ungleich.ch/ungleich-public/cdist)
(needs [**ungleich** account](https://account.ungleich.ch)).
For community-maintained types there is
[**cdist-contrib** project](https://code.ungleich.ch/ungleich-public/cdist-contrib).
## Participating
IRC: ``#cdist`` @ freenode
Matrix: ``#cdist:ungleich.ch``
Mattermost: https://chat.ungleich.ch/ungleich/channels/cdist

View file

@ -32,6 +32,10 @@ case "$os" in
sysctl -n hw.ncpuonline
;;
"freebsd"|"netbsd")
sysctl -n hw.ncpu
;;
*)
if [ -r /proc/cpuinfo ]; then
cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)"

View file

@ -29,7 +29,7 @@ case "$os" in
echo "$(sysctl -n hw.memsize)/1024" | bc
;;
"openbsd")
*"bsd")
echo "$(sysctl -n hw.physmem) / 1048576" | bc
;;

View file

@ -167,7 +167,8 @@ class Explorer(object):
def run_global_explorer(self, explorer):
"""Run the given global explorer and return it's output."""
script = os.path.join(self.remote.global_explorer_path, explorer)
return self.remote.run_script(script, env=self.env, return_output=True)
return self.remote.run_script(script, env=self.env, return_output=True,
warn_return_output=False)
# type
@ -229,7 +230,8 @@ class Explorer(object):
})
script = os.path.join(self.remote.type_path, cdist_type.explorer_path,
explorer)
return self.remote.run_script(script, env=env, return_output=True)
return self.remote.run_script(script, env=env, return_output=True,
warn_return_output=False)
def transfer_type_explorers(self, cdist_type):
"""Transfer the type explorers for the given type to the

View file

@ -219,7 +219,7 @@ class Remote(object):
self._run_command(command)
def run_script(self, script, env=None, return_output=False, stdout=None,
stderr=None):
stderr=None, warn_return_output=True):
"""Run the given script with the given environment on the remote side.
Return the output as a string.
@ -232,10 +232,11 @@ class Remote(object):
command.append(script)
return self.run(command, env=env, return_output=return_output,
stdout=stdout, stderr=stderr)
stdout=stdout, stderr=stderr,
warn_return_output=warn_return_output)
def run(self, command, env=None, return_output=False, stdout=None,
stderr=None):
stderr=None, warn_return_output=True):
"""Run the given command with the given environment on the remote side.
Return the output as a string.
@ -269,10 +270,11 @@ class Remote(object):
else:
cmd.extend(command)
return self._run_command(cmd, env=env, return_output=return_output,
stdout=stdout, stderr=stderr)
stdout=stdout, stderr=stderr,
warn_return_output=warn_return_output)
def _run_command(self, command, env=None, return_output=False, stdout=None,
stderr=None):
stderr=None, warn_return_output=True):
"""Run the given command with the given environment.
Return the output as a string.
@ -280,7 +282,8 @@ class Remote(object):
assert isinstance(command, (list, tuple)), (
"list or tuple argument expected, got: %s" % command)
if return_output and stdout is not subprocess.PIPE:
warn_return_output_applies = warn_return_output and return_output
if warn_return_output_applies and stdout is not subprocess.PIPE:
self.log.debug("return_output is True, ignoring stdout")
close_stdout = False

View file

@ -19,6 +19,9 @@
# such as ':' for POSIX or ';' for Windows.
# If also specified at command line then values from command line are
# appended to this value.
# Notice that this works in a "last one wins" fashion, so if a type is redefined
# in multiple conf_dirs, the last one in which it is defined will be used.
# Consider using a unique prefix for your own roles if this can be an issue.
# conf_dir = <dir1>:<dir2>
#
# init_manifest

View file

@ -10,6 +10,8 @@ next:
* New type: __pf_apply_anchor (Kamila Součková, Evil Ham)
* Type __pf_ruleset: Refactor (Kamila Součková, Evil Ham)
* Type __pf_apply: Deprecate type (Kamila Součková, Evil Ham)
* Configuration: Add notes to cdist.cfg.skeleton (Evil Ham)
* Explorers cpu_cores, memory: Improve *BSD support (Evil Ham)
6.5.4: 2020-04-11
* Explorer init: Do not grep on non-existent init (Steven Armstrong)