Open Grieves

Open Grieves

Assimilate quickly!

You must comply!

Red Hat Satellite 6.0: Automatically publish a content view using hammer

You must readPosted by Magnus Glantz 2015-05-20 12:18:11
If you have a content view that you want to always contain the latest stuff, then you have to automate the process of publishing a new version of the content view and then promoting it to relevant lifecycle environments.

This will likely become easier in Satellite 6.1 as there is a lot of changes going into that version in regards to content views and promotion of content.

Here's a script that I used to do this.

#!/bin/bash
# Magnus Glantz, open.grieves you-know-what-goes-here gmail.com, 2015
# Automatically promote a content view from Library to Production
# Assumes 4 life cycle environments, including Library
# Ugly sleep cycles based on waiting times for content view with only two simple filters, adjust as required. Expect up to 30 minutes delay for complex content views.

# Edit below
USER="theusername"
PASS="thepassword"
# Get contentview id with: hammer -u user -p thepass content-view list --organization Default_Organization
CONTENTVIEW_ID=1234

echo "Remove after having edited above variables." ; exit 0

# Publish a new version of the content view, promotes it to Library as well.
hammer -u $USER -p $PASS content-view publish --id $CONTENTVIEW_ID --organization Default_Organization --async

# Wait 13 minutes for content view to complete publish cycle
sleep 800

# Extract version ID of new content view version
VERSION=$(hammer -u $USER -p $PASS content-view version list --content-view-id $CONTENTVIEW_ID|head -4|tail -1|awk '{ print $1 }')

# Publish new version to Development
hammer -u $USER -p $PASS content-view version promote --content-view-id $CONTENTVIEW_ID --id $VERSION --lifecycle-environment-id 2

# Wait 20 minutes for content view to complete publish cycle
sleep 1200

# Publish new version to Test
hammer -u $USER -p $PASS content-view version promote --content-view-id $CONTENTVIEW_ID --id $VERSION --lifecycle-environment-id 3

# Wait 20 minutes for content view to complete publish cycle
sleep 1200

# Publish new version to Production
hammer -u $USER -p $PASS content-view version promote --content-view-id $CONTENTVIEW_ID --id $VERSION --lifecycle-environment-id 4







  • Comments(0)//blog.hacka.net/#post94