sscheib.satellite_publish_promote_content_views
Satellite Content View Publish and Promote Role
Important Notice:
This role is very complicated. I did my best to test it, but I can't promise that it's completely free of bugs. Because Repository synchronization, Content View publishing, and promoting can affect your Satellite, please test this role before using it in a production environment. It is provided "as is," and I am not responsible for any negative effects it may have. It's best to test on a backup of your Satellite or in a lab system. Thanks for understanding! 🙂
This role publishes and can promote versions of both Content Views and Composite Content Views. It uses the certified Red Hat collection redhat.satellite
.
It has been tested on the following Satellite versions:
- 6.15
- 6.14
- 6.13
To use the redhat.satellite
collection, you need to be a Red Hat subscriber. If you don't have a subscription, you can use Red Hat's Developer Subscription at no cost.
You can also use the upstream collection theforeman.foreman
, but you'll need to change module names from redhat.satellite
to theforeman.foreman
. I haven't tested this approach.
This role accepts Content View definitions in the same way as the role redhat.satellite.content_view_publish
. It supports common role variables from the redhat.satellite
collection.
Common role variables include:
SATELLITE_SERVER_URL
,SATELLITE_SERVER
,SATELLITE_URL
SATELLITE_USERNAME
,SATELLITE_USER
SATELLITE_PASSWORD
SATELLITE_VALIDATE_CERTS
By reusing the same Content View definition from the redhat.satellite
collection, you can maintain the same YAML format for your Content Views. However, I recommend moving to a more modern definition, which is accepted by both Foreman and this role.
You can run this role with the convert
tag (--tags convert
) to convert your definitions into a file of your choice, specified with the variable sat_convert_yaml_file
.
The conversion uses a custom filter provided with this role (list_of_dicts_to_indented_yaml
), which properly indents lists with two spaces. The filter allows for a specific key and value to be placed at the top of a list of dictionaries by default using the name
.
Please note, this filter is not intended for use outside this role, and it will only accept a list of dictionaries.
Since this role requires a specific definition format to function correctly, I highly recommend migrating from legacy YAML definitions. This role can convert definitions on-the-fly but incurs a performance hit as it checks each Content View definition individually. The larger the definition, the bigger the performance impact.
One thing this role does not accept as an argument is current_lifecycle_environment
. It determines the current Lifecycle Environment dynamically.
This role also allows for attributes in satellite_content_views
:
patch_day_exclude
: This permanently excludes a Content View from being processed, for use on "special occasions."lifecycle_environments
: A list of Lifecycle Environments for promotion. This is optional for publishing but required for promoting.
Differences from redhat.satellite.content_view_publish
This role operates quite differently from redhat.satellite.content_view_publish
, which simply publishes all Content Views listed in satellite_content_views
. My role dynamically decides which Content Views to publish or promote based on changes and limits promotion to defined Lifecycle Environments. It checks for no changes before publishing or promoting, and handles exclusions without needing to redefine satellite_content_views
.
This makes it more complex and slower than redhat.satellite.content_view_publish
, but it offers much more flexibility.
I have included many checks to ensure that the data being used is correct, which makes this role more versatile but also more complex. I’ve tried to comment on difficult sections in the code for better understanding.
This role is not suitable for Ansible beginners, and while it could theoretically replace the content_view_publish
role, it might be considered too complex for wider contributions.
When to Use This Role
Consider using this role instead of the official redhat.satellite.content_view_publish
if:
- You want to promote Content View versions while publishing new ones.
- You want to promote only without publishing in an idempotent way.
- You need to promote only to specified Lifecycle Environments in an idempotent manner.
- You want to exclude specific Content Views from publishing on patch days.
- You don't want to worry about the order of Content Views.
- You need to dynamically limit the Lifecycle Environments for promotions.
- You want to publish Content Views based on their last synchronization date.
- You want to promote Composite Content Views only if their components have changed.
- You want to check that repositories are synchronized before publishing.
- You want to synchronize repositories prior to other actions.
- You want to ignore certain check requirements for repositories.
- You want to wait for ongoing repository synchronizations to finish.
Notes
- Using
sat_publish_based_on_repository
only makes sense for Content Views. - The
sat_publish_based_on_component
variable is only relevant for Composite Content Views.
Dependencies
This role requires the Red Hat certified collection redhat.satellite
.
Example Playbook
The example below includes repositories and components, but this is not required for the role and serves only to demonstrate compatibility with the definitions used in the redhat.satellite.content_views
role.
Complex Example
---
- hosts: 'localhost'
gather_facts: false
roles:
- name: 'satellite_content_view_publish_promote'
vars:
sat_async_max_time: 3900
sat_async_poll_time: 0
sat_async_retries: 2000
sat_async_check_delay: 2
sat_content_view_version_description: 'Patch day'
sat_composite_content_view_version_description: 'Patch day'
satellite_server_url: 'https://satellite.example.com'
satellite_organization: 'org-example'
sat_only_promote_content_views: false
sat_only_promote_composite_content_views: false
sat_publish_based_on_repository: true
sat_check_unsynchronized_repositories: true
sat_wait_for_repository_synchronization: true
sat_check_successful_repository_synchronization: true
sat_check_synchronizing_repositories: true
sat_content_view_kinds: 'both'
sat_synchronize_repositories: false
sat_check_content_views_known: true
sat_publish_based_on_component: true
satellite_content_views:
- name: 'cv-rhcdn-base-rhel-8'
lifecycle_environments:
- 'lce-default-dev'
- 'lce-default-prod'
repositories:
- name: 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8'
product: 'Red Hat Enterprise Linux for x86_64'
- name: 'Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8'
product: 'Red Hat Enterprise Linux for x86_64'
# Additional Content Views...
License
GPL-2.0-or-later
Publishes and optionally promotes Content View versions and Composite Content View versions.
ansible-galaxy install sscheib.satellite_publish_promote_content_views