How to seamlessly rename a minion?
Your Minion ID is based on the hostname during the installation. When you change the hostname after you installed the salt-minion, the Minion ID wil not change.
The Minion ID is specified in /etc/salt/minion_id
.
When you change the Minion ID:
- The Minion will identify itself with the new ID to the Master and stops listening to the old ID.
- The Master will detect the new Minion Id as a new Minion and it shows a new key in
Unaccepted Keys
. - After accepting the key on the Master you will be able to use the Minion with the new key only. The old key is still accepted on the Master but doesn't work anymore.
I can come up with two solutions for your situation:
- Use salt-ssh to provision your minions. The Master will connect to your Raspberry PI using SSH. It will setup the correct hostname, install and configure salt-minion. After this is finished, your minion will connect to the master with the correct ID. But this requires the Master to know when and where a minion is available...
- You mentioned the state where the hostname is set. Change the Minion ID and restart the minion service in the same state. This will change the Minion ID but you need to accept the new key afterwards. Note that the minion will never report a state as successfully finished when you restart the salt-minion service in it.