Skip to content

Add ansible collection support - #791

Open
tod-uma wants to merge 7 commits into
splunk:developfrom
tod-uma:ansible-collection
Open

Add ansible collection support#791
tod-uma wants to merge 7 commits into
splunk:developfrom
tod-uma:ansible-collection

Conversation

@tod-uma

@tod-uma tod-uma commented Mar 8, 2024

Copy link
Copy Markdown
Contributor

Why

This makes it possible to consume splunk-ansible as an Ansible collection — installed via ansible-galaxy collection install from a git-sourced requirements.yml — instead of vendoring or symlinking the repo into a project's roles path. That's useful for anyone integrating splunk-ansible's roles into their own playbooks (for example, installing the universal forwarder as one step of a broader Ansible-managed bootstrap process) without maintaining a private fork just to get collection semantics.

Ansible collections need two things this repo doesn't have: a galaxy.yml manifest, and modules living under plugins/modules/ rather than library/ (library/ is the pre-collection, role-local module path; a collection's own modules resolve from plugins/modules/ — see Developing collections).

What

  • galaxy.yml (new) — collection manifest. description, license (matches the repo's actual Apache-2.0 license), tags, and documentation/homepage/issues links to the existing docs site, repo, and issue tracker. version starts at 1.0.0: a collection's version should track its own release history, not whatever Splunk build happens to be current, so it isn't tied to a product version number.
  • library/plugins/modules/ — moves splunk_api.py and es_ta_for_indexers.py to the path a collection resolves its modules from. Done as renames (git mv), so history is preserved on both files.

Verified

ansible-galaxy collection build succeeds and produces a valid splunk-splunk_ansible-1.0.0.tar.gz.

Once installed as a collection:

# collections/requirements.yml
collections:
  - source: https://github.com/splunk/splunk-ansible.git
    version: "10.4.3"   # pin a release tag, not a moving branch
    type: git
# playbook.yml
- hosts: splunk_universal_forwarder
  become: true
  collections:
    - splunk.splunk_ansible
  vars:
    splunk: "{{ splunk_universal_forwarder }}"
  tasks:
    - name: install the forwarder
      ansible.builtin.include_role:
        name: splunk_universal_forwarder

Status

Opened in 2024 and stale since; rebased now onto current develop with no conflicts — this range hasn't touched library/ or galaxy.yml, so both structural changes still apply cleanly. We've been running this on a fork since, alongside several other fixes that have since merged cleanly here (#879, #883, #893, #894), so happy to adjust anything in galaxy.yml — tags especially — to whatever fits the project's own preference.

@tod-uma
tod-uma marked this pull request as ready for review March 8, 2024 15:19
@tod-uma
tod-uma requested a review from a team as a code owner March 8, 2024 15:19
The original galaxy.yml was deliberately minimal ("just enough to get
it to work"). Fill in the fields the collections_galaxy_meta schema
recommends but doesn't require:

- description, so the collection is identifiable on its own in
  ansible-galaxy search/list output, not just by namespace.name
- license, matching the repository's actual Apache-2.0 license
  (docs/LICENSE.md)
- documentation/homepage/issues, pointing at the existing GitHub Pages
  docs, repo, and issue tracker
- tags, replacing the single "collection" tag (redundant -- every
  entry in Galaxy is a collection) with ones that describe what this
  collection actually does

Also reset version to 1.0.0. The collection version should track the
collection's own release history, not the Splunk product version it
happens to manage -- 9.0.2-2 tied the two together from the first
commit and would need a new justification every time Splunk cuts a
release even if the collection's own Ansible code hadn't changed.
@tod-uma

tod-uma commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current develop (no conflicts — this range hasn't touched library/ or galaxy.yml), filled in galaxy.yml's description/license/tags/links, and reset the version to 1.0.0 so it tracks the collection's own history rather than a Splunk build number. Description above has the details.

We've been running this on a fork for a while now, alongside several other small fixes that have since merged cleanly here — #879, #883, #893, #894 — so figured it was worth bringing this one back into view too. Happy to adjust anything, galaxy.yml's tags especially, to match project preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant