This is just a shorter version of https://github.com/Katello/katello/pull/1757 (had a merge conflict and used mine)