Search code examples
salt-project

saltstack: reuse of minion-specific, calculated variables


when using puppet I used to do something like the following:

    class common_vars {
        $some_var = calculate_some_var()
    }

    class A {
        Class[common_vars] -> Class[A]
        do_something_with($common_vars::some_var)
    }

    class B {
        Class[common_vars] -> Class[B]
        do_something_else_with($common_vars::some_var)
    }

I'm now looking for something similar in saltstack.

I used this for example for setting up network services which are bound to a specific network address. I first setup networking, then calculate some common addresses, then setup the network services.

Instead of calculating these addresses (where different services may share the same address) over and over again in each state-file, I'd like to calculate them once, and reuse them later on.


Solution

  • I would do this in Salt's Pillar.

    Here's a walkthrough: http://docs.saltstack.com/topics/tutorials/pillar.html