Beginner question: How to change agent minion_id from master ?

4,363 views
Skip to first unread message

T.J. Yang

unread,
Oct 24, 2014, 4:39:31 PM10/24/14
to salt-...@googlegroups.com
Hi
I am including salt-minion RHEL package in RHEL 5/6 VMWare template with salt master set to our salt master server. 
The VM will get a dhcp hostname/ip and also the dhcp hostname as minion_id. The salt master has auto_accept set to True in /etc/salt/master.

Once the VM got moved to static ip and FQDN, I am stuck with /etc/sal/minion_id with dhcp hostname.

Without using salt, I am doing  following step to update the VM with final minion_id.

1. ssh into dhcp17623.test.com
2. hostname > /etc/salt/minion_id
3. /etc/init.d/salt-minion restart

To automate above steps,without login into salt agent machine,   I ran following salt command 3 commands

salt -L  dhcp176231.test.com cmd.run 'hostname > /etc/salt/minion_id'
salt -L  dhcp176231.test.com cmd.run '/etc/init.d/salt-minion restart'
slat-key -y -d  dhcp176231.test.com

I am getting following warning message after 2nd command, the new minion_id was used by agent and has a successful connection to master.

"No minions matched the target. No command was sent, no jid was assigned."

Is there  a better way ? 

Thanks

tj

Jeff

unread,
Oct 24, 2014, 5:00:52 PM10/24/14
to salt-...@googlegroups.com
I'm curious as well.  I have removed minion_id and restart (on windows).  I think if the minion_id file doesn't exist, it uses the hostname by default and then writes minion_id.  I think the intent is to allow multiple minions to run on a single system by specifying the minion_id.

I wonder if there is a way to force it to always use the hostname and never write out minion_id.

In your case, I think it is getting the rug pulled out from underneath it as you are restarting the minion in the middle of a call and I doubt there is a way to work around that, unless you can request a service restart somehow in a background request so that the salt request returns before the restart is issued.

Otherwise, what process do you use to switch from DHCP to STATIC?  Maybe removing minion_id at that point is more doable?

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeff Vincent
See my LinkedIn profile at:
http://www.linkedin.com/in/rjeffreyvincent

T.J. Yang

unread,
Oct 24, 2014, 5:18:18 PM10/24/14
to salt-...@googlegroups.com
Hi Jeff

Thanks for your reply.

Otherwise, what process do you use to switch from DHCP to STATIC?  Maybe removing minion_id at that point is more doable?

Switching from DHCP to STATIC is handled by two different teams/people.  it is a manual process using GUI operation in vcenter and vi in RHEL OS.
Definitely there is room for further automation.

tj

Stephen Spencer

unread,
Oct 24, 2014, 11:34:34 PM10/24/14
to salt-...@googlegroups.com

You need to rename the key in /etc/salt/pki/master/minions to match the new minion id. You can also reconfigure minions via pillar. The minion_id key in the config will override the minion_id file.

(I think that's the path.. It's close, if not.

-S

--

T.J. Yang

unread,
Sep 6, 2016, 3:06:34 PM9/6/16
to Salt-users

Hi all

Following is the procedure I ended up using to rename Linux host 

# rename hostname.test.com into hostname as minion id.

# as root user on salt-master

export HN=hostname

salt $HN.test.com test.ping && salt $HN.test.com cmd.run 'hostname > /etc/salt/minion_id'

salt $HN.test.com service.restart salt-minion

mv -f /etc/salt/pki/master/minions/$HN.test.com /etc/salt/pki/master/minions/$HN

salt $HN test.ping # check if new host works


Reply all
Reply to author
Forward
0 new messages