Salt: [Feature Request] Use modules in requisites

Created on 12 Feb 2019  路  3Comments  路  Source: saltstack/salt

Description of Issue/Question

Saltstack is historically and by design is not about working with runtime information. One of the features that'd like to see is a requisite which are based on some runtime info.

Here is an example:
I want to run some state but only if the result of the different module is True.

It may look like this:

cmd.run:
  <...>
  - onlyif:  my_custom_module_which_returns_true_or_false

And I want to do it in runtime, not before via Jinja execution of the Salt.

I think it's already possible with slots and onlyif in a way that if slots function will return a string "true" or "false", onlyif will execute it on the system and make a decision based on this.

The executing a shell part is really not necessary and this whole approach is hacky so if we may have a new requisite module just for this that'd be really great.

This idea is inspired by Ansible's condition engine, which allows doing this:

name: Run command
command: "ls -1 /tmp"
register: result_of_command

name: Do something if you should
when: "'file123' in result_of_command.stdout_lines"
module_name:
<...>
Feature

Most helpful comment

All 3 comments

will approve as a feature request. thanks :)

This is a duplicate of #5050

And i am working on implementing it right now.

Was this page helpful?
0 / 5 - 0 ratings