rename windows minion from master

122 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Jeremy Larose

ungelesen,
16.08.2016, 16:37:4016.08.16
an Salt-users
Is there a way to do this? I'd like to clean up my key list and possibly group computers by names.  This is close (works directly on the machine), but salt can't cmd.run it...

powershell "(Get-Content C:\salt\conf\minion) -replace 'id:.*', ('id: newname') | Set-Content C:\salt\conf\minion" && echo newname > C:\salt\conf\minion_id

and then the service would just need to be restarted.

Thanks.

Loren Gordon

ungelesen,
16.08.2016, 21:19:4216.08.16
an Salt-users
Have you tried just using `file.replace`? Also, from a bit of research, looks like you can just delete the minion_id file and let it regenerate.

-Loren

Jeremy Larose

ungelesen,
16.08.2016, 22:54:4916.08.16
an Salt-users
using your suggestion of file.replace, maybe not the cleanest, but this works:

salt 'oldname' file.uncomment 'c:\salt\conf\minion' 'id:'
salt 'oldname' file.replace 'c:\salt\conf\minion' pattern='id: oldname' repl='id: newname'
salt 'oldname' service.restart salt-minion
salt-key -d 'oldname'
salt-key -a 'newname'

Loren Gordon

ungelesen,
17.08.2016, 05:54:3817.08.16
an Salt-users
Looks pretty clean to me. file.replace accepts regex patterns, which you could probably use to uncomment the line.

salt 'oldname' file.replace 'c:\salt\conf\minion' pattern='^[#]?id:.*$' repl='id: newname'

Untested, but, something along those lines...

You can also write a file to 'C:\salt\conf\minion.d\<myconfig.conf>' to store your config settings.

And if you changed the windows computer name, I'm pretty sure you can just remove/rename the minion_id file and restart the minion service. At least, on my own computer, I'm not seeing any other reference to the minion id anywhere, and this does regenerate the minion_id file.

-Loren

Jeremy Larose

ungelesen,
22.08.2016, 10:46:3522.08.16
an Salt-users
It seems as though the main minion config file overrides the minion_id file... but this is the final, one liner that I have been using with success...

salt 'oldname' file.uncomment 'c:\salt\conf\minion' 'id:' && salt 'oldname' file.replace 'c:\salt\conf\minion' pattern='^[#]?id:.*$' repl='id: newname' && salt 'oldname' service.restart salt-minion && salt-key -d 'oldname' -y && sleep 5 && salt-key -a 'newname' -y

Sindhu Reddy

ungelesen,
25.07.2018, 10:45:2925.07.18
an Salt-users
It worked!! Thanks :) That's awesome
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten