Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Salt-Stack: executes states matching a pattern

I want to execute states which match a pattern.

The sls file is called "echo_loop_for_all_systems_of_minion" and in my directory "examples".

I found a way to display the rendered sls file:

salt-ssh  bar-foo state.show_sls  examples.echo_loop_for_all_systems_of_minion

Output:

bar-foo:
    ----------
    modfoo_bar_p_echo:
        ----------
        __sls__:
            examples.echo_loop_for_all_systems_of_minion
        cmd:
            |_
              ----------
              name:
                  /home/modfoo_bar_p/bin/python -c "..."
            - run

    modfoo_bar_q_echo:
        ----------
        __sls__:
            examples.echo_loop_for_all_systems_of_minion
        cmd:
            |_
              ----------
              name:
                  /home/modfoo_bar_q/bin/python -c "..."
            - run

The above file is truncated. I want to run all states which match on this pattern modfoo_bar_*_echo.

Background: We have N systems (python virtualenv) on one minion. I need a way to address only some of them.

like image 608
guettli Avatar asked Dec 14 '25 19:12

guettli


1 Answers

Conceptually, you just write a custom module and put it in your /srv/salt/_modules directory on the master.

Then you call the module from the command-line and pass the filter info into it as parameters.

Here's an request/example that may help you find the data you will need.

like image 197
Dave Neeley Avatar answered Dec 17 '25 11:12

Dave Neeley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!