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..1673751 --- /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. Ansible documentation suggests [removing collections with rm](https://docs.ansible.com/projects/ansible/latest/collections_guide/collections_installing.html#removing-a-collection) + +## 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 "; +}