Skip to content

feat(telco-kpis): Add standalone lockdown JSON parser playbook#455

Open
ccardenosa wants to merge 2 commits intoopenshift-kni:mainfrom
ccardenosa:refactor/ipa-telco-kpis-prow-migration-lockdown-parser
Open

feat(telco-kpis): Add standalone lockdown JSON parser playbook#455
ccardenosa wants to merge 2 commits intoopenshift-kni:mainfrom
ccardenosa:refactor/ipa-telco-kpis-prow-migration-lockdown-parser

Conversation

@ccardenosa
Copy link
Copy Markdown
Collaborator

Add parse-lockdown.yml playbook that extracts deployment parameters from lockdown JSON files, enabling decoupled parameter management for reproducible deployments.

Problem

Telco-KPIs testing requires exact software versions (OCP releases, operator channels, catalogs) for reproducible deployments. Parsing lockdown JSON inline within deployment playbooks creates tight coupling and makes parameter reuse across multiple jobs difficult.

Solution

Implement standalone parser playbook that runs before deployment jobs:

  1. Downloads and parses lockdown JSON from URI
  2. Auto-detects lockdown type (hub vs spoke) from JSON structure
  3. Extracts deployment parameters
  4. Outputs in shell env and JSON formats for downstream consumption

Changes

New playbook: playbooks/telco-kpis/parse-lockdown.yml

  • Auto-detection logic: checks for 'hub' vs 'deployment' key in JSON
  • Hub parsing: extracts OCP_RELEASE_IMAGE, ACM_CHANNEL, MCE_CHANNEL, catalogs
  • Spoke parsing: extracts OCP_PULL_SPEC, ZTP_PULL_SPEC, operator configurations
  • SSL certificate bypass for internal GitLab instances (validate_certs: false)
  • Dynamic artifact naming using lockdown filename from URI
  • Outputs three artifacts per run:
    • {lockdown-name}.json: Original lockdown file
    • {lockdown-name}-params.env: Shell environment variables
    • {lockdown-name}-params.json: Structured JSON parameters

New role: playbooks/telco-kpis/roles/lockdown_hub_config/

  • tasks/main.yml: Download, validate, and parse hub lockdown JSON
  • defaults/main.yml: Default configuration values
  • README.md: Comprehensive role documentation
  • Used by both parse-lockdown.yml and deploy-ocp-operators.yml

Usage Workflow

Step 1: Parse lockdown file

ansible-playbook playbooks/telco-kpis/parse-lockdown.yml \
  -e lockdown_uri=https://gitlab.cee.redhat.com/.../lockdown-hub-x86_64.json

Step 2: Use extracted parameters

# Source env file
source lockdown-hub-x86_64-params.env

# Use in deployment
ansible-playbook playbooks/deploy-ocp-sno.yml \
  -e release="${OCP_RELEASE_IMAGE}"

Benefits

Decoupling:

  • Parsing separated from deployment logic
  • Parameters extracted once, reused across multiple jobs
  • Easier debugging with explicit parameter artifacts

Flexibility:

  • Supports multiple lockdown formats (hub, spoke, baseline)
  • Self-documenting artifacts with actual lockdown names
  • Both shell and JSON output formats

Prow-ready:

  • Clean separation aligns with Prow step registry architecture
  • Parser step can run independently, output shared via SHARED_DIR

Key Features

Auto-detection:

lockdown_type: "{{ 'hub' if ('hub' in lockdown_data) else 'spoke' }}"

Dynamic artifact naming:

lockdown_filename: "{{ lockdown_uri | regex_replace('.*/', '') | regex_replace('.json$', '') }}"
# Result: lockdown-hub-x86_64-params.env (not generic lockdown-params.env)

Hub channel transformations:

hub_acm_channel: "release-{{ lockdown_data.hub.acm.version_override }}"
hub_mce_channel: "{{ lockdown_data.hub.acm.mce_override | regex_replace('^v', 'stable-') | regex_replace('\\.\\d+$', '') }}"

Example Artifacts

lockdown-hub-x86_64-params.env:

LOCKDOWN_TYPE=hub
OCP_RELEASE_IMAGE=quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64
OCP_VERSION=4.20
ACM_CHANNEL=release-2.13
MCE_CHANNEL=stable-2.8
TALM_CATALOG=quay.io/.../talm-index:v4.20
GITOPS_CATALOG=quay.io/.../gitops-index:v1.15

lockdown-hub-x86_64-params.json:

{
  "LOCKDOWN_TYPE": "hub",
  "OCP_RELEASE_IMAGE": "quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64",
  "OCP_VERSION": "4.20",
  "ACM_CHANNEL": "release-2.13",
  "MCE_CHANNEL": "stable-2.8",
  "TALM_CATALOG": "quay.io/.../talm-index:v4.20",
  "GITOPS_CATALOG": "quay.io/.../gitops-index:v1.15"
}

Verification

Tested with both lockdown types:

  • Hub lockdown: Successfully extracted OCP 4.20.4 pull spec and operator channels
  • Spoke lockdown: Successfully extracted spoke deployment parameters

Artifacts correctly named with lockdown filename and contain expected parameters.

Related: Telco-KPIs reproducible deployment system

@openshift-ci openshift-ci Bot requested review from kononovn and mkochanowski May 6, 2026 18:03
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 6, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cplacani for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

ccardenosa added 2 commits May 6, 2026 20:20
Implement role-based container image mirroring system for internal registry
management, supporting both mirror and removal operations with authentication.

## Problem

Telco-KPIs testing requires mirroring container images to internal registries
for disconnected environments and test image management. Previous approach used
inline playbook tasks without reusability.

## Solution

Created dedicated `container_image_mirror` Ansible role with playbooks for both
mirroring and removal operations:

**Role: playbooks/roles/container_image_mirror/**
- Supports 'mirror' and 'remove' operations via parameter
- Uses skopeo for image operations
- Handles authentication with pull secrets
- Continues operation even if some images fail
- Comprehensive success/failure reporting with summary

**Playbooks:**
- `playbooks/mirror-images.yml` - Mirror images to internal registry
- `playbooks/remove-images.yml` - Remove images from registry storage

## Features

**Authentication:**
- Pull secret support for private registries (via pull_secret_string or pull_secret_path)
- System default auth when no pull secret provided
- Configurable auth file location (/tmp for bastion compatibility)
- use_pull_secret flag to control authentication method

**Registry Configuration:**
- Configurable registry host/port/namespace
- TLS verification control
- Source and destination registry support

**Operations:**
- Idempotent with existence checks
- Detailed mirror/removal summary
- Error handling continues operation on failures

## Usage

**Mirror images:**
```bash
ansible-playbook playbooks/mirror-images.yml \
  -e images='[{"source": "quay.io/image:tag", "dest": "registry.local/namespace/image:tag"}]' \
  -e registry_host=registry.local \
  -e pull_secret_string='{"auths": {...}}'
```

**Remove images:**
```bash
ansible-playbook playbooks/remove-images.yml \
  -e images='[{"dest": "registry.local/namespace/image:tag"}]' \
  -e registry_host=registry.local
```

## Implementation Details

**Role Structure:**
- `defaults/main.yaml` - Default variables
- `tasks/main.yaml` - Entry point with operation dispatch
- `tasks/mirror.yaml` - Mirror images using skopeo
- `tasks/remove.yaml` - Remove images from registry storage
- `meta/main.yaml` - Role metadata
- `README.md` - Comprehensive documentation

**Key Variables:**
- `container_image_mirror_operation`: "mirror" or "remove"
- `container_image_mirror_images`: List of image objects
- `container_image_mirror_registry_host`: Target registry hostname
- `container_image_mirror_pull_secret_string`: JSON pull secret
- `container_image_mirror_use_pull_secret`: Enable/disable authentication

## Benefits

- Reusable role for both mirror and removal operations
- Cleaner separation of concerns
- Easier to test and maintain
- Follows eco-ci-cd role patterns (like ocp_operator_mirror)
- Well-documented with examples
- Jenkins job compatible (uses same variable names)

## Jenkins Integration

Used by `telco-kpis-mirror-ran-test-images` Jenkins job for mirroring RAN test
images to internal registries.

Related: Telco-KPIs test infrastructure
Signed-off-by: Carlos Cardenosa <ccardeno@redhat.com>
Add parse-lockdown.yml playbook that extracts deployment parameters from
lockdown JSON files, enabling decoupled parameter management for reproducible
deployments.

## Problem

Telco-KPIs testing requires exact software versions (OCP releases, operator
channels, catalogs) for reproducible deployments. Parsing lockdown JSON inline
within deployment playbooks creates tight coupling and makes parameter reuse
across multiple jobs difficult.

## Solution

Implement standalone parser playbook that runs before deployment jobs:
1. Downloads and parses lockdown JSON from URI
2. Auto-detects lockdown type (hub vs spoke) from JSON structure
3. Extracts deployment parameters
4. Outputs in shell env and JSON formats for downstream consumption

## Changes

**New playbook: playbooks/telco-kpis/parse-lockdown.yml**
- Auto-detection logic: checks for 'hub' vs 'deployment' key in JSON
- Hub parsing: extracts OCP_RELEASE_IMAGE, ACM_CHANNEL, MCE_CHANNEL, catalogs
- Spoke parsing: extracts OCP_PULL_SPEC, ZTP_PULL_SPEC, operator configurations
- SSL certificate bypass for internal GitLab instances (validate_certs: false)
- Dynamic artifact naming using lockdown filename from URI
- Outputs three artifacts per run:
  - `{lockdown-name}.json`: Original lockdown file
  - `{lockdown-name}-params.env`: Shell environment variables
  - `{lockdown-name}-params.json`: Structured JSON parameters

**New role: playbooks/telco-kpis/roles/lockdown_hub_config/**
- tasks/main.yml: Download, validate, and parse hub lockdown JSON
- defaults/main.yml: Default configuration values
- README.md: Comprehensive role documentation
- Used by both parse-lockdown.yml and deploy-ocp-operators.yml

## Usage Workflow

**Step 1: Parse lockdown file**
```bash
ansible-playbook playbooks/telco-kpis/parse-lockdown.yml \
  -e lockdown_uri=https://gitlab.cee.redhat.com/.../lockdown-hub-x86_64.json
```

**Step 2: Use extracted parameters**
```bash
# Source env file
source lockdown-hub-x86_64-params.env

# Use in deployment
ansible-playbook playbooks/deploy-ocp-sno.yml \
  -e release="${OCP_RELEASE_IMAGE}"
```

## Benefits

**Decoupling:**
- Parsing separated from deployment logic
- Parameters extracted once, reused across multiple jobs
- Easier debugging with explicit parameter artifacts

**Flexibility:**
- Supports multiple lockdown formats (hub, spoke, baseline)
- Self-documenting artifacts with actual lockdown names
- Both shell and JSON output formats

**Prow-ready:**
- Clean separation aligns with Prow step registry architecture
- Parser step can run independently, output shared via SHARED_DIR

## Key Features

**Auto-detection:**
```yaml
lockdown_type: "{{ 'hub' if ('hub' in lockdown_data) else 'spoke' }}"
```

**Dynamic artifact naming:**
```yaml
lockdown_filename: "{{ lockdown_uri | regex_replace('.*/', '') | regex_replace('.json$', '') }}"
# Result: lockdown-hub-x86_64-params.env (not generic lockdown-params.env)
```

**Hub channel transformations:**
```yaml
hub_acm_channel: "release-{{ lockdown_data.hub.acm.version_override }}"
hub_mce_channel: "{{ lockdown_data.hub.acm.mce_override | regex_replace('^v', 'stable-') | regex_replace('\\.\\d+$', '') }}"
```

## Example Artifacts

**lockdown-hub-x86_64-params.env:**
```bash
LOCKDOWN_TYPE=hub
OCP_RELEASE_IMAGE=quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64
OCP_VERSION=4.20
ACM_CHANNEL=release-2.13
MCE_CHANNEL=stable-2.8
TALM_CATALOG=quay.io/.../talm-index:v4.20
GITOPS_CATALOG=quay.io/.../gitops-index:v1.15
```

**lockdown-hub-x86_64-params.json:**
```json
{
  "LOCKDOWN_TYPE": "hub",
  "OCP_RELEASE_IMAGE": "quay.io/openshift-release-dev/ocp-release:4.20.4-x86_64",
  "OCP_VERSION": "4.20",
  "ACM_CHANNEL": "release-2.13",
  "MCE_CHANNEL": "stable-2.8",
  "TALM_CATALOG": "quay.io/.../talm-index:v4.20",
  "GITOPS_CATALOG": "quay.io/.../gitops-index:v1.15"
}
```

## Verification

Tested with both lockdown types:
- Hub lockdown: Successfully extracted OCP 4.20.4 pull spec and operator channels
- Spoke lockdown: Successfully extracted spoke deployment parameters

Artifacts correctly named with lockdown filename and contain expected parameters.

Related: Telco-KPIs reproducible deployment system
Signed-off-by: Carlos Cardenosa <ccardeno@redhat.com>
@ccardenosa ccardenosa force-pushed the refactor/ipa-telco-kpis-prow-migration-lockdown-parser branch from e880769 to 507eed0 Compare May 6, 2026 18:54
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