Switching puppet masters on puppet clients for Windows

Daniel Schutterop
08-01-2014

Sometimes you’d like to migrate a puppet agent from one puppet master to the other, in most cases, this isn’t a problem at all.

Some problems occur however, when you try to switch puppet masters on puppet clients for Windows. While you want to change the puppet.conf file to point to a new (intermediate) host (this to avoid a big-bang scenario for all puppet agents) using Puppet itself, the Windows agent has the tendency to leave a lockfile (search for puppetdlock) which makes it quite impossible to change the agent through a puppet run. A nice catch-22 there.

A possible solution is to remove the lockfile through a Visual Basic script, as shown below:

remove_puppetlock.vbs
' Complementair aan de puppet module "win-puppet-migrate
'
' Date: 27-01-2014
' Author: D. Schutterop
' Version: v1
'
' Purpose:
' Omdat de puppet agent in sommige gevallen blijft hangen,
' En zo de migratie naar een andere puppet server erg lastig is,
' haalt dit script de lockfile van puppet weg zodat deze weer responsive kan worden
'
' Input: CSCRIPT