salt-project

SaltStack : is it possible to apply states on the master and if so, how?


I am a total beginner with SaltStack but I have managed to setup some states on a machine and run them on a minion.

What I have right now is a Debian machine setup with salt-master as well as another Debian setup as salt-minion.

Since I am using the salt-master also as a development machine, I would like to know if I can somehow apply the states on the master itself as well. And if so, how?

Is there a command I can run to apply the states on the master? (so far I was unable to find it)

Should I install salt-minion on the same machine as well to be able to do this and simply register the same machine as a minion on itself?

Thanks!


Solution

  • Since I am using the salt-master also as a development machine, I would like to know if I can somehow apply the states on the master itself as well. And if so, how?

    You can do that by following the following steps:

    1. Install salt-minion on your development machine
    2. Edit /etc/salt/minion to point to your master (vi /etc/salt/minion and change the following : master: salt -> master: 127.0.0.1)
      • (optional) Edit /etc/salt/minion_id to something that is meaningful to you
    3. Start up your salt-minion
    4. Use salt-key to accept your minion's key
    5. Use your salt-master to control your minion as if it were any other salt-minion

    Is there a command I can run to apply the states on the master?

    The salt-master doesn't really run the the state files, the salt-minions do. If you followed the above steps then you can target your salt-master to run highstate with the following command:

    salt 'the_value_of_/etc/salt/minion_id' state.highstate
    

    Should I install salt-minion on the same machine as well to be able to do this and simply register the same machine as a minion on itself?

    Yup. I think you have an idea as to what you need to do and just need a push in the right direction.