Skip to content

Add feature_flag module for Automation Platform Gateway#95

Merged
rohitthakur2590 merged 3 commits intoansible:develfrom
fao89:feature_flags
Nov 25, 2025
Merged

Add feature_flag module for Automation Platform Gateway#95
rohitthakur2590 merged 3 commits intoansible:develfrom
fao89:feature_flags

Conversation

@fao89
Copy link
Copy Markdown
Member

@fao89 fao89 commented Nov 12, 2025

Description

  • What is being changed? Add a new feature_flag module to manage Automation Platform Gateway feature flags
  • Why is this change needed? To provide Ansible users with the ability to view and configure runtime feature flags in AAP Gateway, enabling better control over platform features
  • How does this change address the issue? Implements a complete module with supporting utilities, comprehensive documentation, integration tests, and practical examples for managing feature flags

This PR introduces comprehensive support for feature flag management, including:

  • New ansible.platform.feature_flag module for managing AAP Gateway feature flags
  • Supporting utility classes (AAPFeatureFlag) with proper API integration
  • Safety checks to prevent modification of install-time flags
  • Comprehensive integration tests covering all use cases
  • Example playbook demonstrating common feature flag operations

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test update
  • Refactoring (no functional changes)
  • Development environment change
  • Configuration change

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

  • AAP Gateway instance running and accessible
  • Runtime feature flags enabled in AAP Gateway settings (RUNTIME_FEATURE_FLAGS=True)
  • Valid authentication credentials (username/password or token)
  • At least one runtime feature flag available for testing

Steps to Test

Basic Functionality Test

  1. Run the example playbook:
    ansible-playbook examples/feature_flag_management.yml -e gateway_admin_password=<password>

Integration Test

  1. Install the collection locally:

    make collection-install
  2. Run the feature flag integration tests:

    make collection-test-integration TARGET=feature_flags_test

Manual Module Testing

  1. Check if a feature flag exists:

    - name: Check feature flag
      ansible.platform.feature_flag:
        name: FEATURE_EXAMPLE_ENABLED
        state: exists
  2. Update a runtime feature flag:

    - name: Enable feature flag
      ansible.platform.feature_flag:
        name: FEATURE_EXAMPLE_ENABLED
        value: "True"
        state: present

Expected Results

  • Module should successfully retrieve feature flag information for exists state
  • Runtime feature flags can be enabled/disabled with present state
  • Install-time feature flags should fail with appropriate error message when attempting to modify
  • Integration tests should pass with no errors
  • Check mode should work correctly without making actual changes
  • Idempotency should be maintained (no changes when value is already correct)

Additional Context

Key Features

  • Safety First: Prevents modification of install-time feature flags and validates runtime flag settings
  • Comprehensive State Management: Supports exists, present, enforced, and absent states (though absent is blocked for safety)
  • Validation: Checks if runtime feature flags are enabled and validates boolean values
  • Idempotency: Module is fully idempotent and supports check mode
  • Error Handling: Comprehensive error handling for common scenarios (missing flags, invalid values, disabled runtime flags)

Implementation Details

  • Follows existing collection patterns using AAPObject base class
  • Uses PATCH method for updates (as required by AAP Gateway API)
  • Includes comprehensive documentation with examples and return values
  • Integration tests cover all supported operations and error conditions

API Integration

  • Uses /api/gateway/v1/feature_flags/ endpoint
  • Validates against settings endpoint to ensure runtime flags are enabled
  • Properly handles AAP Gateway authentication patterns

Required Actions

  • Requires documentation updates
  • Requires downstream repository changes
  • Requires infrastructure/deployment changes
  • Requires coordination with other teams
  • Blocked by PR/MR: #XXX

Screenshots/Logs

Module output example:

{
  "id": 1,
  "name": "FEATURE_EXAMPLE_ENABLED",
  "ui_name": "Example Feature",
  "condition": "boolean",
  "value": "True",
  "toggle_type": "run-time",
  "description": "Enables example functionality",
  "changed": true
}

@fao89 fao89 force-pushed the feature_flags branch 6 times, most recently from 7e08980 to 859c5e9 Compare November 12, 2025 10:34
@fao89 fao89 marked this pull request as draft November 12, 2025 10:36
@rohitthakur2590 rohitthakur2590 self-requested a review November 21, 2025 10:43
Comment thread plugins/modules/feature_flag.py
@fao89 fao89 marked this pull request as ready for review November 24, 2025 20:46
Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@fao89 fao89 force-pushed the feature_flags branch 5 times, most recently from cb5e393 to 89ce3be Compare November 25, 2025 13:59
This commit adds a new Ansible module for managing feature flags in the
Automation Platform Gateway. The module allows users to view and update
runtime feature flags while providing appropriate validation and error
handling for different flag types and states.

Key features:
- Support for checking, enabling, and disabling runtime feature flags
- Validation that prevents modification of install-time flags
- Boolean value validation for boolean condition flags
- Comprehensive integration tests with error handling scenarios
- Example playbook demonstrating usage patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
- Simplify error message assertion to match actual API behavior
- The API returns validation errors one at a time, not all at once
- Fix typo: "Rereate" -> "Recreate"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
@github-actions
Copy link
Copy Markdown

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

@fao89
Copy link
Copy Markdown
Member Author

fao89 commented Nov 25, 2025

@rohitthakur2590 could you please merge?

@rohitthakur2590 rohitthakur2590 merged commit 7293dbc into ansible:devel Nov 25, 2025
14 checks passed
nickbhasin pushed a commit to nickbhasin/ansible.platform that referenced this pull request Jan 7, 2026
* Explicitly error when getting gateway/DAB PRs fail

Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED

* AAP-45878 - Add feature_flag module for Automation Platform Gateway

This commit adds a new Ansible module for managing feature flags in the
Automation Platform Gateway. The module allows users to view and update
runtime feature flags while providing appropriate validation and error
handling for different flag types and states.

Key features:
- Support for checking, enabling, and disabling runtime feature flags
- Validation that prevents modification of install-time flags
- Boolean value validation for boolean condition flags
- Comprehensive integration tests with error handling scenarios
- Example playbook demonstrating usage patterns

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED

* Fix authenticator_maps_test validation error handling

- Simplify error message assertion to match actual API behavior
- The API returns validation errors one at a time, not all at once
- Fix typo: "Rereate" -> "Recreate"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Fabricio Aguiar <fabricio.aguiar@gmail.com>

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
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.

2 participants