From 53d6f125f91de23b79a5bf4b345ef7bad2e72984 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Thu, 29 Jan 2026 11:25:19 -0600 Subject: [PATCH 1/2] Added package-method-ansible-galaxy-collection --- cfbs.json | 9 +++++++++ .../README.md | 18 ++++++++++++++++++ ...ackage-method-ansible-galaxy-collections.cf | 15 +++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 management/package-method-ansible-galaxy-collection/README.md create mode 100644 management/package-method-ansible-galaxy-collection/package-method-ansible-galaxy-collections.cf diff --git a/cfbs.json b/cfbs.json index e05a954..a9787f2 100644 --- a/cfbs.json +++ b/cfbs.json @@ -177,6 +177,15 @@ "bundles powershell_execution_policy_inventory" ] }, + "package-method-ansible-galaxy-collection": { + "description": "Package method for installing Ansible Galaxy Collections.", + "subdirectory": "management/package-method-ansible-galaxy-collection", + "dependencies": [], + "steps": [ + "directory ./ services/cfbs/modules/package-method-ansible-galaxy-collection/", + "policy_files services/cfbs/modules/package-method-ansible-galaxy-collection/" + ] + }, "package-method-winget": { "description": "Package method for Windows winget package manager.", "subdirectory": "management/package-method-winget", diff --git a/management/package-method-ansible-galaxy-collection/README.md b/management/package-method-ansible-galaxy-collection/README.md new file mode 100644 index 0000000..b42c11d --- /dev/null +++ b/management/package-method-ansible-galaxy-collection/README.md @@ -0,0 +1,18 @@ +# package-method-ansible-galaxy-collection + +## Usage +This module enables a `ansible-galaxy-collection` package method used with policy like: + +```cf3 +packages: + "ansible.posix" + package_method => ansible_galaxy_collection, + package_policy => "add"; +``` + +Note that there is not a command option in ansible-galaxy to uninstall collections so that will result in no changes being made and a warning message. + +## Installation + +This module does not ensure that needed ansible packages are installed to provide the `ansible-galaxy` command. +Typically this is a package named `ansible` on Debian-based distributions or `ansible-core` on RedHat-based distributions. diff --git a/management/package-method-ansible-galaxy-collection/package-method-ansible-galaxy-collections.cf b/management/package-method-ansible-galaxy-collection/package-method-ansible-galaxy-collections.cf new file mode 100644 index 0000000..1720036 --- /dev/null +++ b/management/package-method-ansible-galaxy-collection/package-method-ansible-galaxy-collections.cf @@ -0,0 +1,15 @@ +body package_method ansible_galaxy_collection +{ + package_changes => "bulk"; + package_name_convention => "$(name)"; + package_delete_convention => "$(name)"; + + package_installed_regex => ".*"; + package_list_name_regex => '^"([^"]*)",.*'; + package_list_version_regex => '.*,"([^"]*)".*'; + + + package_list_command => "ansible-galaxy collection list"; + package_delete_command => 'echo "Deleting an Ansible Galaxy Collection is not supported"'; + package_add_command => "ansible-galaxy collection install "; +} From 91f9ee86d1f071f6f3eb0fce86c946e2fea76802 Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Fri, 30 Jan 2026 10:21:54 -0600 Subject: [PATCH 2/2] Update management/package-method-ansible-galaxy-collection/README.md Co-authored-by: Nick Anderson --- management/package-method-ansible-galaxy-collection/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/management/package-method-ansible-galaxy-collection/README.md b/management/package-method-ansible-galaxy-collection/README.md index b42c11d..1673751 100644 --- a/management/package-method-ansible-galaxy-collection/README.md +++ b/management/package-method-ansible-galaxy-collection/README.md @@ -10,7 +10,7 @@ packages: package_policy => "add"; ``` -Note that there is not a command option in ansible-galaxy to uninstall collections so that will result in no changes being made and a warning message. +Note that there is not a command option in ansible-galaxy to uninstall collections so that will result in no changes being made and a warning message. Ansible documentation suggests [removing collections with rm](https://docs.ansible.com/projects/ansible/latest/collections_guide/collections_installing.html#removing-a-collection) ## Installation