Tech:Salt

Miraheze uses salt-minions to do automated things like running puppet accross all hosts almost instantly.

Salt Minions
Salt minions are on all hosts where we want to do salt commands.

To run a salt command, ssh into misc4 and run:

salt -E '.*' cmd.run 'puppet agent -tv'

To limit the command to certain hosts like mw* do the following:

salt -E 'mw.*' cmd.run 'puppet agent -tv'

To run it against for example cp* and mw* do:

salt -E '(mw*|cp*)' cmd.run 'puppet agent -tv'

To depool one of mw* from cp* do the following:

salt -E "cp.*" cmd.run "sudo varnishadm backend.set_health mw3 sick"

To repool do the following:

salt -E "cp.*" cmd.run "sudo varnishadm backend.set_health mw3 auto"

To list status of backends do the following:

salt -E "cp.*" cmd.run "sudo varnishadm backend.list"

Salt Master
When you install salt-minion on a new host, you need to accept the key on the master, to see if you need to do that run:

sudo salt-key --list all

If the host is listed in "Unaccepted Keys:" then run the following

sudo salt-key -a

To remove a host do the following:

sudo salt-key -d