Tuesday, 23 August 2016

Salt-stack connect minion to a different master

This is a guide if you want to connect a minion from one master to a different master.


You have a minion ex. minion1 and it is currently connected to master1. Now for some reason you want to connect to a different master ex master2. I had this requirement when I had to create a clone of a live ec2 instances minions which is already connected to live-master and I had to connect it to a master which we use for development i.e. dev-master.

NOTE:  I am assuming the OS to be Ubuntu

The following are the steps.
  • SSH into minion and Shutdown salt-minion on the minion instance using sudo service salt-minion stop (Optional)
  • Restart master2 in open mode(This is temporary, This will make it easier) by doing the following
    • In master2 (/etc/salt/master) configuration set open_mode: True
    • Restart salt-master using sudo service salt-master restart
  • Change ID(Optional), master IP/HOST and master_finder of minion by doing the following
    • ssh to minion
    • do sudo vim /etc/salt/minion
    • search for id: and change it if needed.
    • search for master: IP/HOST, change the IP or HOST for the master2
    • search for master_finger: and delete the property. This is newly added so It may not be there in configuration.
    • Remove key for old master(master1) server rm /etc/salt/pki/minion/minion_master.pub
    • Restart minion sudo service salt-minion restart
  • Change open_mode to False or remove the property(by default is False) and restart master2.

This should allow the minion to connect to the master2. Now there are things which you would need to change depending on the requirement. Like I was creating a different environment by cloning liveand we have a grain named circle set for the environments like devstaging or live. So had to change the grain to livetest.
salt '*.livetest.example.com' grains.setval circle livetest
Hope it helps.

Any suggestions or questions are welcome.

Ideaapplied Technologies provides comprehensive QA services. Visit us at ideaapplied.com to know more about our services

No comments:

Post a Comment