Skip to content

Commit 736974f

Browse files
committed
Update the release process for Ansible Galaxy collections
1 parent 5ba962c commit 736974f

1 file changed

Lines changed: 51 additions & 53 deletions

File tree

docs/release_process.md

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -262,22 +262,22 @@ The general rule is that the PR Titles will compose the body of the changelog.
262262
263263
This set of commands describes how to create and push the release tag.
264264
It also updates the **stable** branch with the latest released tag.
265-
```
266-
release=v0.1.99
267-
remote=origin
265+
```
266+
release=v0.1.99
267+
remote=origin
268268
269-
# get up-to-date branches and tags from github
270-
git fetch --tags $remote
269+
# get up-to-date branches and tags from github
270+
git fetch --tags $remote
271271
272-
# create a new tag based on latest stabilization
273-
git tag $release $remote/stabilization
272+
# create a new tag based on latest stabilization
273+
git tag $release $remote/stabilization
274274
275-
# push the tag
276-
git push $remote $release
277-
# update the stable branch, merging in the new tag
278-
hash=$(git commit-tree $release^{tree} -p $remote/stable -p $release -m "Merge in $release")
279-
git push $remote $hash:stable
280-
```
275+
# push the tag
276+
git push $remote $release
277+
# update the stable branch, merging in the new tag
278+
hash=$(git commit-tree $release^{tree} -p $remote/stable -p $release -m "Merge in $release")
279+
git push $remote $hash:stable
280+
```
281281
282282
- Wait for the release action to finish. You can follow the Workflow runs in this link:
283283
- https://github.com/ComplianceAsCode/content/actions/workflows/release.yaml
@@ -352,9 +352,11 @@ updated to reflect the latest content.
352352
--build-playbooks-dir <unzipped built ansible playbooks dir> \
353353
--token <github_dev_token> \
354354
--local-roles-dir /tmp/ansible-roles \
355-
--tag-release
355+
--tag-release \
356+
--organization 'RedHatOfficial'
356357
```
357358
359+
358360
> **_NOTE:_** It is also possible to use a GitHub user/password combination if the token is not
359361
provided.
360362
@@ -406,66 +408,62 @@ the latest content.
406408
Unlike the individual Ansible roles — which are synced to Galaxy from their GitHub repositories —
407409
the collection is published as a tarball uploaded directly to Ansible Galaxy.
408410
409-
## Test the Collection Locally
410-
411-
Before publishing, verify the full pipeline locally:
411+
## Create and build the Collection
412412
413-
```bash
414-
# 1. Build the data stream and generate Ansible roles for a product
415-
ADDITIONAL_CMAKE_OPTIONS="-DSSG_ANSIBLE_ROLES_ENABLED=TRUE" \
416-
./build_product rhel9 --datastream
417-
ninja -C build generate-rhel9-ansible-roles
418-
419-
# 2. Generate and build the collection
420-
python3 utils/ansible_roles_to_collection.py \
421-
--roles-dir build/ansible_roles \
422-
--output-dir /tmp/test-collection \
423-
--build
424-
425-
# 3. Verify no unrewritten FQCNs remain in the bundled roles
426-
grep -r "community\.general\.\|ansible\.posix\." \
427-
/tmp/test-collection/ansible_collections/redhatofficial/rhel_hardening_roles/roles/ \
428-
&& echo FAIL || echo OK
429-
```
430-
431-
## Build the Collection Tarball
432-
433-
- The roles were already saved to `/tmp/ansible-roles` by the previous step. Run the following
434-
command to generate and build the collection tarball:
413+
1. Build and test the Collections for unrewritten FQCNs
435414
```bash
436-
python3 utils/ansible_roles_to_collection.py \
437-
--roles-dir /tmp/ansible-roles \
438-
--output-dir /tmp/ansible-collection \
439-
--build
415+
# Initialize the environment
416+
. .pyenv.sh
417+
418+
OUTPUT_DIR="ansible-galaxy-collections"
419+
420+
for version in rhel8 rhel9 rhel10; do
421+
# 1. Enable generation of Ansible roles and build the data stream
422+
ADDITIONAL_CMAKE_OPTIONS="-DSSG_ANSIBLE_ROLES_ENABLED=TRUE" \
423+
./build_product $version --datastream
424+
# This generates the roles in build/ansible_roles
425+
ninja -C build generate-$version-ansible-roles
426+
427+
mkdir -p "$OUTPUT_DIR/$version/ansible_roles"
428+
cp -r build/ansible_roles $OUTPUT_DIR/$version/ansible_roles
429+
430+
# 2. Generate and build the individual collections
431+
python3 utils/ansible_roles_to_collection.py \
432+
--roles-dir $OUTPUT_DIR/$version/ansible_roles \
433+
--output-dir $OUTPUT_DIR/$version \
434+
435+
# 3. Verify no unrewritten FQCNs remain in the bundled roles
436+
grep -r "community\.c\.\|ansible\.posix\." \
437+
$OUTPUT_DIR/$version/ansible_collections/redhatofficial/rhel_hardening_roles/roles/ \
438+
&& echo FAIL || echo OK
439+
done
440440
```
441441
442-
If roles for each RHEL major version were built and saved separately (e.g. by a downstream
443-
process that builds one product at a time), pass `--roles-dir` once per source directory and
444-
the script will merge them before bundling:
442+
2. Generate a Collection tarball:
445443
```bash
446444
python3 utils/ansible_roles_to_collection.py \
447-
--roles-dir /tmp/ansible-roles-rhel8 \
448-
--roles-dir /tmp/ansible-roles-rhel9 \
449-
--roles-dir /tmp/ansible-roles-rhel10 \
450-
--output-dir /tmp/ansible-collection \
445+
--roles-dir $OUTPUT_DIR/rhel8/ansible_roles \
446+
--roles-dir $OUTPUT_DIR/rhel9/ansible_roles \
447+
--roles-dir $OUTPUT_DIR/rhel10/ansible_roles \
448+
--output-dir $OUTPUT_DIR/ansible-collections-tarball \
451449
--build
452450
```
453451
454452
This will:
455453
1. Download and vendor modules from `community.general` and `ansible.posix`.
456454
2. Bundle all roles for the allowed products into the `redhatofficial.rhel_hardening_roles` collection.
457-
3. Build the collection tarball (e.g. `redhatofficial-rhel_hardening_roles-0.1.82.tar.gz`).
455+
3. Build the collection tarball in the `./ansible-collections-tarball` folder.
458456
459457
> **_NOTE:_** The collection version is read automatically from `CMakeLists.txt` at the
460458
> checked-out tag, so it will match the release version without needing to be specified manually.
461459
462-
## Upload to Ansible Galaxy
460+
## Upload the Collection tarball to Ansible Galaxy
463461
464462
Upload the tarball manually through the Ansible Galaxy web interface:
465463
466464
1. Log in to https://galaxy.ansible.com with your Red Hat account.
467465
2. Navigate to the `redhatofficial` namespace.
468-
3. Click **Import** and upload the generated `.tar.gz` file from `/tmp/ansible-collection/`.
466+
3. For the `rhel_hardening_roles` collection, select `Upload new version` and select the generated tarball from the previous steps.
469467
470468
> **_NOTE:_** In the future this step can be automated by passing `--galaxy-token <token>` to
471469
> `ansible_roles_to_collection.py`, which will upload the tarball to Galaxy via the API without

0 commit comments

Comments
 (0)