[Katello] Promote Content View versions automatically

Hi

I want to schedule and automate the whole publishing and promotion process.
Suppose I have the following Lifecycle Environment Path:
Library->Dev->Test->Stage->Prod. Now I want to every week promote new
Content View version to the next level. To do that I need to know versions
or version IDs. Since versions are rotating and I every week publish new
version I have to manually check them before I promote them. That does not
scale very well. Is there a way how to promote, say Stage to Prod, Test to
Stage, Dev to Test and Library to Dev without providing any version
numbers. So, basically what I want to do is to say: Stage env. will now be
Prod, Test is now Stage etc.

I cannot figure out how to make it automatically with Hammer without doing
some complicated grep'ing and sed'ing.

Any ideas?

Edgars

Hi

Anyone?

Edgars

pirmdiena, 2015. gada 14. decembris 13:25:06 UTC+1, Edgars M. rakstīja:

··· > > Hi > > I want to schedule and automate the whole publishing and promotion > process. Suppose I have the following Lifecycle Environment Path: > Library->Dev->Test->Stage->Prod. Now I want to every week promote new > Content View version to the next level. To do that I need to know versions > or version IDs. Since versions are rotating and I every week publish new > version I have to manually check them before I promote them. That does not > scale very well. Is there a way how to promote, say Stage to Prod, Test to > Stage, Dev to Test and Library to Dev without providing any version > numbers. So, basically what I want to do is to say: Stage env. will now be > Prod, Test is now Stage etc. > > I cannot figure out how to make it automatically with Hammer without doing > some complicated grep'ing and sed'ing. > > Any ideas? > > Edgars >

https://github.com/evgeni/katello-cvmanager may be helpful

··· On Tue, May 31, 2016 at 1:38 PM, Edgars M. wrote:

Hi

Anyone?

Edgars

pirmdiena, 2015. gada 14. decembris 13:25:06 UTC+1, Edgars M. rakstīja:

Hi

I want to schedule and automate the whole publishing and promotion
process. Suppose I have the following Lifecycle Environment Path:
Library->Dev->Test->Stage->Prod. Now I want to every week promote new
Content View version to the next level. To do that I need to know versions
or version IDs. Since versions are rotating and I every week publish new
version I have to manually check them before I promote them. That does not
scale very well. Is there a way how to promote, say Stage to Prod, Test to
Stage, Dev to Test and Library to Dev without providing any version
numbers. So, basically what I want to do is to say: Stage env. will now be
Prod, Test is now Stage etc.

I cannot figure out how to make it automatically with Hammer without
doing some complicated grep’ing and sed’ing.

Any ideas?

Edgars


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Edgars,

I can't think of anything other than complicated hammer scripts and the
tool mentioned above (very cool, btw). If you would like to see something
like this in a future version of katello, feel free to put in a feature
request here Foreman (be
sure to select "Feature" in the Tracker section)

Thanks,

John Mitsch
Red Hat Engineering
(860)-967-7285
irc: jomitsch

··· On Tue, May 31, 2016 at 8:56 AM, Sean O'Keeffe wrote:

https://github.com/evgeni/katello-cvmanager may be helpful

On Tue, May 31, 2016 at 1:38 PM, Edgars M. edgars.mazurs@gmail.com > wrote:

Hi

Anyone?

Edgars

pirmdiena, 2015. gada 14. decembris 13:25:06 UTC+1, Edgars M. rakstīja:

Hi

I want to schedule and automate the whole publishing and promotion
process. Suppose I have the following Lifecycle Environment Path:
Library->Dev->Test->Stage->Prod. Now I want to every week promote new
Content View version to the next level. To do that I need to know versions
or version IDs. Since versions are rotating and I every week publish new
version I have to manually check them before I promote them. That does not
scale very well. Is there a way how to promote, say Stage to Prod, Test to
Stage, Dev to Test and Library to Dev without providing any version
numbers. So, basically what I want to do is to say: Stage env. will now be
Prod, Test is now Stage etc.

I cannot figure out how to make it automatically with Hammer without
doing some complicated grep’ing and sed’ing.

Any ideas?

Edgars


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

Thanks John

I tried that tool, but unfortunately I could not make it do what I want… I
guess I am doing something wrong, but I will try again.

Edgars

otrdiena, 2016. gada 7. jūnijs 23:31:48 UTC+2, John Mitsch rakstīja:

··· > > Edgars, > > I can't think of anything other than complicated hammer scripts and the > tool mentioned above (very cool, btw). If you would like to see something > like this in a future version of katello, feel free to put in a feature > request here http://projects.theforeman.org/projects/katello/issues/new > (be sure to select "Feature" in the Tracker section) > > Thanks, > > John Mitsch > Red Hat Engineering > (860)-967-7285 > irc: jomitsch > > On Tue, May 31, 2016 at 8:56 AM, Sean O'Keeffe > wrote: > >> https://github.com/evgeni/katello-cvmanager may be helpful >> >> On Tue, May 31, 2016 at 1:38 PM, Edgars M. > > wrote: >> >>> Hi >>> >>> Anyone? >>> >>> Edgars >>> >>> pirmdiena, 2015. gada 14. decembris 13:25:06 UTC+1, Edgars M. rakstīja: >>>> >>>> Hi >>>> >>>> I want to schedule and automate the whole publishing and promotion >>>> process. Suppose I have the following Lifecycle Environment Path: >>>> Library->Dev->Test->Stage->Prod. Now I want to every week promote new >>>> Content View version to the next level. To do that I need to know versions >>>> or version IDs. Since versions are rotating and I every week publish new >>>> version I have to manually check them before I promote them. That does not >>>> scale very well. Is there a way how to promote, say Stage to Prod, Test to >>>> Stage, Dev to Test and Library to Dev without providing any version >>>> numbers. So, basically what I want to do is to say: Stage env. will now be >>>> Prod, Test is now Stage etc. >>>> >>>> I cannot figure out how to make it automatically with Hammer without >>>> doing some complicated grep'ing and sed'ing. >>>> >>>> Any ideas? >>>> >>>> Edgars >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Foreman users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to foreman-user...@googlegroups.com . >>> To post to this group, send email to forema...@googlegroups.com >>> . >>> Visit this group at https://groups.google.com/group/foreman-users. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-user...@googlegroups.com . >> To post to this group, send email to forema...@googlegroups.com >> . >> Visit this group at https://groups.google.com/group/foreman-users. >> For more options, visit https://groups.google.com/d/optout. >> > >

I am using this script with hammer scheduled on a certain day of the month. First I have a sync in foreman to update all repos. then I schedule the following script.
The script autopublishes and promotes to all environments (except Library). You can run it manually or in a cron job

$ cat /content_view_env_promote.sh
#!/bin/bash

# Script to autopublish synced repos and promote to environments
# Author: Besmir Zanaj
# Variables
ORG="<YOUR_ORG>"

# Get all content views
CV_IDS=$(hammer --csv --no-headers content-view list --fields "Content View ID")

# autopublish synced repos
for i in $CV_IDS
do
  if [[ "$i" -ne 1 ]]; then # Default Organization View does not need versioning
    echo $i
    hammer content-view publish --id $i --organization-label $ORG --async
  fi
done

# Promote to the environments
for CV_ID in "$CV_IDS"
do 
  for i in $(hammer --csv lifecycle-environment list --organization $ORG | grep -vi '^ID' | awk -F, {'print $1'} | sort -n)
  do
    hammer content-view version promote --organization $ORG --to-lifecycle-environment-id $i --id $CV_ID
  done
done