We have a daily sync plan in place for 3 content views. We then publish this content to dev 1st Monday each Month. Is there a way to automate this publish?
Thanks,
Foreman 3.6, Katello 4.8
We have a daily sync plan in place for 3 content views. We then publish this content to dev 1st Monday each Month. Is there a way to automate this publish?
Thanks,
Foreman 3.6, Katello 4.8
We use a cronjob starting a shell script using hammer like
for i in 2 3 7 8 9 10 12 13 14 15
do
hammer content-view info --id $i --fields THIN
hammer --output silent content-view publish --id $i --lifecycle-environments Testing --organization ORG
hammer --output silent content-view purge --id $i
done
We use Ansible/AWX to publish twenty-one content views and five composites. A/A also sets the update schedule for all our Linux hosts each month. The schedule varies because it is the week of the third Tuesday (a legacy requirement I cannot change) and each host has a specific time and day during that week. When each host completes updates (or not), we receive an email with the result. It is hands-off unless a host goes sideways. A/A is also useful for many other tasks. We use “TheForeman.Foreman” collection which includes several excellent modules for manipulating content views.
thanks, I’ve just setup similar but one script for publishing to library, then another script to promote to dev. Didn’t know you could add that lifecycle flag when publishing. Saves me running a 2nd command
Do you happen to know if more than 1 lifecycle environment can be added to that hammer command? For the next couple of months we are applying updates at same time to both dev and prod
so like could we run "–lifecycle-environments Testing,Prod or similar?
Nice. We use Ansible a lot in our infra but not for anything Foreman related. Well we do have a playbook to add a new client via Katello but that’s it. I like the sound of your setup
Yes. See command help:
--lifecycle-environment[s|-ids] LIST Names/idsentifiers for Lifecycle Environment
If you want to promote into both environments you can use a list there.
We usually publish into testing first and the day after promote that into production. With the promote command you can choose which version to be promoted, e.g.
hammer content-view version promote --content-view-id=$i --organization ORG --from-lifecycle-environment Testing --to-lifecycle-environment Production
The full script looks like this:
echo -n "Publishing and promoting... "
date
for i in 2 3 7 8 9 10 12 13 14 15
do
hammer content-view info --id $i --fields THIN
hammer content-view version promote --content-view-id=$i --organization ORG --from-lifecycle-environment Testing --to-lifecycle-environment Production
done
sleep 300
#for i in 11 12 17 18 19 20
for i in 2 3 7 8 9 10 12 13 14 15
do
hammer content-view info --id $i --fields THIN
time hammer --output silent content-view publish --id $i --lifecycle-environments Testing --organization ORG
hammer --output silent content-view purge --id $i
done
date
The sleep in the middle is to avoid to much overlap in the syncs to the content proxies…
Some automatic publishing flows with Ansible are described in Migrating from cvmanager to Foreman Ansible Modules — Foreman Ansible Modules documentation
thank you both, really appreciate it
@gvde I had a play with the command before your reply and using “–lifecycle-environments dev,prod” seems to have worked. I will check once the proxies are synced and if not will use the to and from flags you’ve given me