Discovery and the task interface¶
Use case: compose the collection's public tasks with ordinary Ansible
control flow — discover resources dynamically, then loop over the
normalized records to converge each one. This is the pattern the
team-resources live probe
uses under a bounded token: gitlab_settings_discover returns
resources records with a stable identifier, and each record feeds a
gitlab_settings task. Under a bounded credential, scope discovery
through the boundary's own parent — an unscoped listing is refused
locally.
Source: examples/public-task-interface.yml
---
- name: Discover and reconcile GitLab resources with ordinary task loops
hosts: localhost
gather_facts: false
connection: local
vars:
gitlab_settings_target:
url: https://gitlab.example.com
auth:
type: personal_access_token
token: "{{ vault_gitlab_admin_token }}"
tasks:
- name: Discover all groups
primetheus.gitlab_settings.gitlab_settings_discover:
target: "{{ gitlab_settings_target }}"
resource: group
scope: all
register: discovered_groups
- name: Enable Duo for every discovered group
primetheus.gitlab_settings.gitlab_settings:
target: "{{ gitlab_settings_target }}"
resource: group
identifier: "{{ item['identifier'] }}"
settings:
duo:
duo_features_enabled: true
duo_availability: default_on
loop: "{{ discovered_groups['resources'] }}"
loop_control:
label: "{{ item['identifier'] }}"
- name: Discover active users
primetheus.gitlab_settings.gitlab_settings_discover:
target: "{{ gitlab_settings_target }}"
resource: user
filters:
active: true
register: discovered_users
- name: Add every active user to the platform group
primetheus.gitlab_settings.gitlab_settings:
target: "{{ gitlab_settings_target }}"
resource: member
parent:
resource: group
identifier: platform
identifier:
user_id: "{{ item['id'] }}"
settings:
access_level: developer
loop: "{{ discovered_users['resources'] }}"
loop_control:
label: "{{ item['identifier'] }}"
- name: Discover unprotected branches in one project
primetheus.gitlab_settings.gitlab_settings_discover:
target: "{{ gitlab_settings_target }}"
resource: branch
parent:
resource: project
identifier: platform/service
filters:
protected: false
register: discovered_branches