You are here: / home / 2018 / 04

Wed, 04 Apr 2018

Automatic OTRS ticket creation for Debian package updates

I recently stumbled about the problem, that I have to create specific tickets in our OTRS system for package upgrades on our Debian servers. Background is, that we use OTRS for our ITIL change management processes.

To be more precise: The actual problem isn't to create the tickets - there are plenty of tools to do that, but to create them in a way I found them useful. apticron not only sends a mail for pending package upgrades (and downloads them if you want to), it also calls apt-listchanges which will show you the changelog entries of the packages you are about to install. You see so not only that you have to install upgrades, but also why.

However, I didn't found a way to change the mail, or add a specific header to the mail. Which would have been a big plus - as you can remote control OTRS via e-mail header quite a lot. And as I am lazy, that is something I definitely wanted to have.

Same for unattended-upgrades. Nice tool, but doesn't allow to change the mail content / header. (At least I didn't found a way to do so.)

I was pleasantly surprised, that cron-apt not only allows to add headers, it also lists some examples for OTRS headers in its documentation! However, by default it only lists (and downloads) packages to be upgrades. No changelogs. There is an open whishlist bug to get this feature added, but considering the age of the bug, I wouldn't hold my breath till it is implemented ;)

There is a solution for this problem, though. Although it is a bit ugly: And as I'm apparently not the only one interested in it, I'll write it down here (partly because I'm interested to find out, if my blog is still working after quite some years of inactivity). The basic idea is to call apt-listchanges on all deb files in /var/cache/apt/archives/. As there might be some cruft laying around, you'll have to run apt-clean before that. As we have a proxy and enough bandwidth that is acceptable in our case.

First you'll have to install the cron-apt and apt-listchanges. Add a file into /etc/cron-apt/action.d/1-clean containing: clean. This will cause cron-apt to call apt-get clean on each invocation and this cleaning all files in /var/cache/apt/archives. Next create a file /etc/cron-apt/action.d/4-listchanges containing the line:/var/cache/apt/archives/*.deb and a file /etc/cron-apt/config.d/4-listchanges containing the lines:

APTCOMMAND=/usr/bin/apt-listchanges
OPTIONS=""

Finally we have to configure cron-apt to actually mail our stuff. Thus create /etc/cron-apt/config similar and add the following:

# where to send mails
MAILTO="otrs@ourcompany.example"
# mail, when the apt calls create output (see documentation for other options)
MAILON="output"

XHEADER1="X-OTRS-Priority: 3 normal - prio 3"
XHEADER2="X-OTRS-Queue: The::Queue::You:Want::it::in"
XHEADER3="X-OTRS-SenderType: system"
XHEADER4="X-OTRS-Loop: false"
XHEADER5="X-OTRS-DynamicField-...: ..."
..
..
..

Bingo! Automated tickets for our change management process with all information required and automated as much as possible to avoid clicking through the web interface.

postet at 16:51 into [Debian] permanent link


About

Alexander Tolimar Reichle-Schmehl lives in Tuttlingen / Germany. He works as IT manager (specialized on Unix and SAN/Storage) for an international automotive supplier.

Links