0

I wonder to know if it is possible to install and remove packages when we change a state of node?
To clarify what I mean here is an example:

Groups:
Load balancer
Web server
Database

Nodes:
Minion1
Minion2
Minion3

If we add Minion1 to the group "Web server" then we have to install Java and Tomcat server on it. If remove Minion1 from "Web server" group then we have to remove Java and Tomcat server from it. If we add Minion 2 to both groups "Load balancer" and "Database" then we have to install Nginx and MySQL. If we remove Minion2 from the group "Database" and add Minion2 to the "Web server" then we have to remove MySQL from it and install Java and Tomcat on it. And so on..

Is it possible to configure Salt to act like this? Maybe some alternatives?

1 Answer 1

0

You can set up each group to contain states that work with pkg states in such a way that they determine both what needs to be installed as well as what needs to be purged.

It does however seem like a strange approach. Typically if you want to replace a node, you remove the old virtual machine altogether, and instantiate a new virtual machine for the new role. That way you make sure things are clean and don't risk arbitrary changes to have been made that might interfere with the new role.

2
  • Thank you for suggestion! But I don't have virtual machines. Only bare machines. Could you please show an example of such groups?
    – Oleksandr
    Apr 11, 2017 at 12:55
  • The same logic works with physical machines - do a clean reinstall (using an automated method) and apply a different Salt state on top of it. If physical reinstall is too much of a hassle, I'd even suggest enabling virtualization and booting a single VM that gets all the resources of a physical server, just to be able to have everything unrelated to hardware nicely sequestered. Apr 11, 2017 at 13:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .