Sunday, August 3, 2014

Deleting a User from RT using Shredder via the Command Line


Sometimes you just want to do one simple thing... but the internet just wont tell you how!

This was one of those times, I just wanted to delete a user from RT, the Request Tracker software.  In v3.8.2 - which we currently run - this isn't an option in the GUI, you have to do it using rt-shredder on the command line.

So, I sigh and move on from the inexplicable nature of this missing feature and login to the CLI to do just that.  Then I find the documentation (see link above), which I think was beautifully described by Philip Brown in this mailing list post when he said:

"Unfortunately... i find the documentation on it, inscruitable :("

 Which it is.  So I had to work it out myself.  Which was no small thing.  I even went to the trouble of snapshotting my RT VM in case I blew away more users than I intended.  However I did work out what Philip and I were both wanting (just a away to delete a single user).  So I'm documenting it here, for prosperity, and because someone responsible for the RT plugin should've done it themselves in the first place.

To delete a single user, by email address, who is not disabled, use the command:

rt-shredder --plugin 'Users=email,me@host.com;status,enabled'

It deletes disabled users by default, so if your users are disabled you wont need  ";status,enabled"


Note - If the user has tickets you may also get a message like "couldn't find resolver for dependency...".  That means you have to reassign their tickets to someone else (the suggestion is to assign then to nobody), in that case the command becomes:

rt-shredder --plugin 'Users=email,me@host.com;status,enabled;replace_relations,6' 

Where "6" is the id of the "nobody" user or whichever user you want to assign the tickets to. 

Hope that helps.

No comments: