Logging Module for Salt
-
Copy the contents of the
_modulesand_statesdirectories into those same directories under your{file_roots}on your salt-master. -
Install the modules on the minions with
state.highstate, orsaltutil.sync_all
Use this module for outputting the contents of variables to the log file. You can output to each of the log levels:
-
debug
-
info
-
warning
-
error
-
critical
Logs will be written to wherever you have salt configured to write logs.
{% set myvar = salt['pillar.get']('foo') %}
{% do salt['logger.debug'](myvar, "(module) pillar[foo]: ") %}With debug logging enabled, this might log:
[DEBUG ] (module) pillar[foo]: {'aliases': ['fubar'],
'favorites': [{'foods': ['chocolate', 'strawberries']},
{'phrase': ['Oh! F@#%!']}],
'friends': ['bar', 'baz'],
'name': 'foo'}
test:
logging.error:
- obj: {{ salt['pillar.get']('foo') }}
- string: '(state) pillar[foo]: 'Using the same pillar as the previous example:
[ERROR ] (state) pillar[foo]: {'aliases': ['fubar'],
'favorites': [{'foods': ['chocolate', 'strawberries']},
{'phrase': ['Oh! F@#%!']}],
'friends': ['bar', 'baz'],
'name': 'foo'}
|
Note
|
This example ouputs log level error. |