Last active
December 30, 2015 02:59
-
-
Save quantonganh/7766786 to your computer and use it in GitHub Desktop.
Salt - cmd.run loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ulimit/absent.sls | |
``` | |
{% for file in salt['cmd.run']('ls /Users/quanta/salt.ulimit*') %} | |
{{ file }}: | |
file: | |
- absent | |
{% endfor %} | |
``` | |
salt '*' cmd.run 'ls /Users/quanta/salt.ulimit*' | |
MacBook-Pro.local: | |
/Users/quanta/salt.ulimit1 | |
/Users/quanta/salt.ulimit2 | |
salt '*' state.sls ulimit.absent | |
---------- | |
Rendering SLS ulimit.absent failed, render error: while parsing a block mapping | |
in "<unicode string>", line 2, column 1: | |
/: | |
^ | |
expected <block end>, but found ':' | |
in "<unicode string>", line 107, column 1: | |
: | |
^ | |
Traceback (most recent call last): | |
File "/usr/local/lib/python2.7/site-packages/salt/state.py", line 1964, in render_state | |
rendered_sls=mods | |
File "/usr/local/lib/python2.7/site-packages/salt/template.py", line 69, in compile_template | |
ret = render(input_data, env, sls, **render_kwargs) | |
File "/usr/local/lib/python2.7/site-packages/salt/renderers/yaml.py", line 34, in render | |
data = load(yaml_data, Loader=get_yaml_loader(argline)) | |
File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 71, in load | |
return loader.get_single_data() | |
File "/usr/local/lib/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data | |
node = self.get_single_node() | |
File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 36, in get_single_node | |
document = self.compose_document() | |
File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 55, in compose_document | |
node = self.compose_node(None, None) | |
File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 84, in compose_node | |
node = self.compose_mapping_node(anchor) | |
File "/usr/local/lib/python2.7/site-packages/yaml/composer.py", line 127, in compose_mapping_node | |
while not self.check_event(MappingEndEvent): | |
File "/usr/local/lib/python2.7/site-packages/yaml/parser.py", line 98, in check_event | |
self.current_event = self.state() | |
File "/usr/local/lib/python2.7/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key | |
"expected <block end>, but found %r" % token.id, token.start_mark) | |
ParserError: while parsing a block mapping | |
in "<unicode string>", line 2, column 1: | |
/: | |
^ | |
expected <block end>, but found ':' | |
in "<unicode string>", line 107, column 1: | |
: | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since
cmd.run
returns a string (include "\n"), try this: