Some times you want to automatically remove nodes from the hub, either because they have been re-imaged and the hub has a "ghost" entry of the old node or because they have been decomissioned entirely.
Removing ghost nodes
The script below will automatically remove the *oldest* node if there are two nodes with the same hostname (but different hostkey).
The script resides in the CFEngine core repository under contrib/enterprise and is currently available at this direct link.
Removing old nodes
The script above can be adjusted to remove old nodes (independent if there are duplicates in the database or not).