Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
gateway_settings:

Check warning on line 2 in collections/ansible_collections/osac/config_as_code/roles/aap/vars/controller.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use aap_ as a prefix. (vars: gateway_settings)
gateway_access_token_expiration: 7200

# Create a project from the specified git repo
Expand Down Expand Up @@ -331,23 +331,47 @@
# provisioning races on VAST resources. This serializes all tenant operations
# through a single AAP worker. Acceptable for current scale; for high-volume
# tenant provisioning, consider per-tenant locking instead.
- name: "{{ aap_prefix }}-create-org"
- name: "{{ aap_prefix }}-create-tenant-storage-backend"
project: "{{ aap_prefix }}"
organization: "{{ aap_organization_name }}"
job_type: run
playbook: "playbook_osac_configure_tenant_storage.yml"
playbook: "playbook_osac_create_tenant_storage_backend.yml"
inventory: "{{ aap_prefix }}-storage-operations"
execution_environment: "{{ aap_prefix }}-ee"
instance_groups:
- "{{ aap_prefix }}-storage-operations-ig"
allow_simultaneous: false
ask_variables_on_launch: true
verbosity: 0
- name: "{{ aap_prefix }}-delete-org"
- name: "{{ aap_prefix }}-create-tenant-cluster-storage"
project: "{{ aap_prefix }}"
organization: "{{ aap_organization_name }}"
job_type: run
playbook: "playbook_osac_delete_tenant_storage.yml"
playbook: "playbook_osac_create_tenant_cluster_storage.yml"
inventory: "{{ aap_prefix }}-storage-operations"
execution_environment: "{{ aap_prefix }}-ee"
instance_groups:
- "{{ aap_prefix }}-storage-operations-ig"
allow_simultaneous: false
ask_variables_on_launch: true
verbosity: 0
- name: "{{ aap_prefix }}-delete-tenant-cluster-storage"
project: "{{ aap_prefix }}"
organization: "{{ aap_organization_name }}"
job_type: run
playbook: "playbook_osac_delete_tenant_cluster_storage.yml"
inventory: "{{ aap_prefix }}-storage-operations"
execution_environment: "{{ aap_prefix }}-ee"
instance_groups:
- "{{ aap_prefix }}-storage-operations-ig"
allow_simultaneous: false
ask_variables_on_launch: true
verbosity: 0
- name: "{{ aap_prefix }}-delete-tenant-storage-backend"
project: "{{ aap_prefix }}"
organization: "{{ aap_organization_name }}"
job_type: run
playbook: "playbook_osac_delete_tenant_storage_backend.yml"
inventory: "{{ aap_prefix }}-storage-operations"
execution_environment: "{{ aap_prefix }}-ee"
instance_groups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ argument_specs:
choices:
- setup
- ensure_storage_class
- teardown
- teardown_cluster_storage
- teardown_backend
description: >
Which storage operation to perform. setup provisions provider-side
resources. ensure_storage_class creates K8s Secret and StorageClass
on the target cluster (JIT). teardown removes all provisioned resources.
on the target cluster. teardown_cluster_storage removes cluster-side
K8s resources (StorageClasses, VolumeSnapshotClasses, CSI Secret)
without touching backend resources or hub Secret. teardown_backend
removes backend resources (VAST tenant, views, quotas) and hub
Secret without touching cluster-side K8s resources.
storage_provider_provisioning_target:
type: str
required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Receives from caller (via loop_var or set_fact):
# _current_provider — the provider name for this iteration (e.g. 'vast')
# _dispatch_action — task file to invoke (setup, ensure_storage_class, teardown)
# _dispatch_action — task file to invoke (setup, ensure_storage_class, teardown_cluster_storage, teardown_backend)
#
# Uses from play scope:
# storage_provider_tiers — full tier list (filtered here per provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
ansible.builtin.fail:
msg: >-
Invalid storage_provider_action '{{ storage_provider_action }}'. Must be one of:
setup, ensure_storage_class, teardown.
when: storage_provider_action not in ['setup', 'ensure_storage_class', 'teardown']
setup, ensure_storage_class, teardown_cluster_storage, teardown_backend.
when: storage_provider_action not in ['setup', 'ensure_storage_class', 'teardown_cluster_storage', 'teardown_backend']

- name: Extract unique providers from tier list
ansible.builtin.set_fact:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# Dispatches teardown_backend to each unique provider in the tier list.
# Removes backend resources (VAST tenant, views, quotas) and hub Secret
# without touching cluster-side K8s resources.
# Best-effort — ignore_errors so one provider's failure doesn't block others.

- name: Dispatch teardown_backend to each provider
block:
- name: Run teardown_backend per provider
ansible.builtin.include_tasks: _dispatch_provider.yaml
loop: "{{ _unique_providers }}"
loop_control:
loop_var: _current_provider
ignore_errors: true # noqa: ignore-errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# Dispatches teardown_cluster_storage to each unique provider in the tier list.
# Removes cluster-side K8s resources (StorageClasses, VolumeSnapshotClasses,
# CSI Secret) without touching backend resources or hub Secret.
# Best-effort — ignore_errors so one provider's failure doesn't block others.

- name: Dispatch teardown_cluster_storage to each provider
block:
- name: Run teardown_cluster_storage per provider
ansible.builtin.include_tasks: _dispatch_provider.yaml
loop: "{{ _unique_providers }}"
loop_control:
loop_var: _current_provider
ignore_errors: true # noqa: ignore-errors
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
# VAST teardown: live-query cleanup of all tenant resources.
# K8s resources are deleted by label selector (catches JIT-created SCs).
# VMS resources are queried live by tenant_id (no reliance on static tier list).
# VAST teardown_backend: remove backend resources and hub Secret only.
# Deletes VAST VMS resources (views, quotas, policies, tenant, manager,
# local provider) and the per-tenant hub Secret.
# Does NOT touch cluster-side K8s resources (StorageClasses, VolumeSnapshotClasses,
# CSI Secret) — use cleanup action for those.

- name: Fail if provisioning target is not yet supported
when: _provisioning_target != 'vmaas'
ansible.builtin.fail:
msg: >-
VAST storage provisioning for target '{{ _provisioning_target }}' is not yet
VAST storage teardown_backend for target '{{ _provisioning_target }}' is not yet
implemented. Only 'vmaas' is currently supported.

- name: Validate tenant_name is a valid DNS label
Expand All @@ -33,7 +35,7 @@
_vast_teardown_tenant_id: "{{ _vast_teardown_config.resources[0].data.vast_tenant_id | b64decode }}"
no_log: true

- name: Cleanup VAST resources
- name: Cleanup VAST backend resources
block:
- name: Resolve VAST admin credentials for VMS API cleanup
ansible.builtin.include_tasks: read_credentials.yaml
Expand Down Expand Up @@ -67,60 +69,6 @@
ansible.builtin.set_fact:
_vast_teardown_tenant_id: "{{ _vast_teardown_tenant_lookup.tenants.id | string }}"

# ── K8s resources: delete by label selector ──

- name: Find all tenant StorageClasses by label
kubernetes.core.k8s_info:
api_version: storage.k8s.io/v1
kind: StorageClass
label_selectors:
- "osac.openshift.io/tenant={{ tenant_name }}"
- "app.kubernetes.io/managed-by=osac-aap"
register: _vast_teardown_sc_list

- name: Delete tenant StorageClasses
kubernetes.core.k8s:
state: absent
api_version: storage.k8s.io/v1
kind: StorageClass
name: "{{ item.metadata.name }}"
loop: "{{ _vast_teardown_sc_list.resources | default([]) }}"
loop_control:
label: "{{ item.metadata.name }}"
ignore_errors: true # noqa: ignore-errors

- name: Find all tenant VolumeSnapshotClasses by label
kubernetes.core.k8s_info:
api_version: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
label_selectors:
- "osac.openshift.io/tenant={{ tenant_name }}"
- "app.kubernetes.io/managed-by=osac-aap"
register: _vast_teardown_vsc_list
ignore_errors: true # noqa: ignore-errors

- name: Delete tenant VolumeSnapshotClasses
when: _vast_teardown_vsc_list.resources is defined
kubernetes.core.k8s:
state: absent
api_version: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
name: "{{ item.metadata.name }}"
loop: "{{ _vast_teardown_vsc_list.resources | default([]) }}"
loop_control:
label: "{{ item.metadata.name }}"
ignore_errors: true # noqa: ignore-errors

- name: Delete CSI Secret in tenant namespace
kubernetes.core.k8s:
state: absent
api_version: v1
kind: Secret
name: "vast-csi-{{ tenant_name }}"
namespace: "{{ tenant_namespace }}"
ignore_errors: true # noqa: ignore-errors
no_log: true

# ── VMS resources: query live by tenant_id ──

- name: Authenticate to VAST VMS as admin
Expand Down Expand Up @@ -241,7 +189,7 @@
ansible.builtin.debug:
msg: >-
Tenant config Secret preserved because one or more resources failed to delete.
Re-run teardown to retry (idempotent).
Re-run teardown_backend to retry (idempotent).

always:
- name: Clear all credential facts from play scope
Expand All @@ -261,12 +209,11 @@
_vast_teardown_tenant_id: ""
no_log: true

- name: Report teardown summary
- name: Report backend teardown summary
ansible.builtin.debug:
msg: >-
Teardown for tenant '{{ tenant_name }}' complete.
K8s: {{ (_vast_teardown_sc_list.resources | default([]) | length) }} SCs,
{{ (_vast_teardown_vsc_list.resources | default([]) | length) }} VSCs deleted.
Backend teardown for tenant '{{ tenant_name }}' complete.
VMS: {% for r, v in (_vast_cleanup_results | default({})).items() %}{{ v.queried }} {{ r }}{{ ', ' if not loop.last else '' }}{% endfor %} deleted.
Tenant: {{ 'ok' if not (_vast_teardown_tenant_result.failed | default(false)) else 'failed' }},
Manager: {{ 'ok' if not (_vast_manager_delete_failed | default(false)) else 'failed' }}.
Hub Secret: {{ 'deleted' if (_vast_teardown_clean | default(false) | bool) else 'preserved' }}.
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
# VAST cleanup: remove cluster-side K8s resources only.
# Deletes StorageClasses, VolumeSnapshotClasses, and CSI Secret by label selector.
# Does NOT delete VAST VMS resources, hub Secret, or CSI operator.
# Used when a cluster is deleted but the tenant stays (resources may be
# needed on other clusters).

- name: Fail if provisioning target is not yet supported
when: _provisioning_target != 'vmaas'
ansible.builtin.fail:
msg: >-
VAST storage teardown_cluster_storage for target '{{ _provisioning_target }}' is not yet
implemented. Only 'vmaas' is currently supported.

- name: Validate tenant_name is a valid DNS label
ansible.builtin.fail:
msg: "tenant_name '{{ tenant_name }}' is not a valid DNS label."
when: tenant_name is not regex('^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$')

- name: Clean up cluster-side K8s resources
block:
- name: Find all tenant StorageClasses by label
kubernetes.core.k8s_info:
api_version: storage.k8s.io/v1
kind: StorageClass
label_selectors:
- "osac.openshift.io/tenant={{ tenant_name }}"
- "app.kubernetes.io/managed-by=osac-aap"
register: _vast_cleanup_sc_list

- name: Delete tenant StorageClasses
kubernetes.core.k8s:
state: absent
api_version: storage.k8s.io/v1
kind: StorageClass
name: "{{ item.metadata.name }}"
loop: "{{ _vast_cleanup_sc_list.resources | default([]) }}"
loop_control:
label: "{{ item.metadata.name }}"
ignore_errors: true # noqa: ignore-errors

- name: Find all tenant VolumeSnapshotClasses by label
kubernetes.core.k8s_info:
api_version: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
label_selectors:
- "osac.openshift.io/tenant={{ tenant_name }}"
- "app.kubernetes.io/managed-by=osac-aap"
register: _vast_cleanup_vsc_list
ignore_errors: true # noqa: ignore-errors

- name: Delete tenant VolumeSnapshotClasses
when: _vast_cleanup_vsc_list.resources is defined
kubernetes.core.k8s:
state: absent
api_version: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
name: "{{ item.metadata.name }}"
loop: "{{ _vast_cleanup_vsc_list.resources | default([]) }}"
loop_control:
label: "{{ item.metadata.name }}"
ignore_errors: true # noqa: ignore-errors

- name: Delete CSI Secret in tenant namespace
kubernetes.core.k8s:
state: absent
api_version: v1
kind: Secret
name: "vast-csi-{{ tenant_name }}"
namespace: "{{ tenant_namespace }}"
ignore_errors: true # noqa: ignore-errors
no_log: true

- name: Report teardown_cluster_storage summary
ansible.builtin.debug:
msg: >-
Teardown of cluster-side resources for tenant '{{ tenant_name }}' complete.
{{ (_vast_cleanup_sc_list.resources | default([]) | length) }} StorageClasses,
{{ (_vast_cleanup_vsc_list.resources | default([]) | length) }} VolumeSnapshotClasses,
1 CSI Secret removed from target cluster.
Backend resources and hub Secret untouched.

rescue:
- name: Warn about teardown_cluster_storage failure (target cluster may be unreachable)
ansible.builtin.debug:
msg: >-
Teardown of cluster-side resources failed for tenant '{{ tenant_name }}'.
This may be expected if the target cluster is being destroyed.
Error: {{ ansible_failed_result.msg | default('unknown') }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- name: Configure storage for a tenant
- name: Create StorageClasses and CSI driver on target cluster (Stage 2)
hosts: localhost
gather_facts: false

Expand Down Expand Up @@ -45,16 +45,6 @@
Expected a JSON array of tier objects with name, protocol, and provider fields.

tasks:
- name: Configure tenant storage
ansible.builtin.include_role:
name: osac.service.storage_provider
vars:
storage_provider_action: setup
storage_provider_tiers: "{{ _storage_tiers }}"
storage_provider_provisioning_target: vmaas
storage_provider_block_encryption_passphrase: "{{ ansible_eda.event.payload.spec.blockEncryptionPassphrase | default('') }}"
storage_provider_snapshots_enabled: "{{ _storage_snapshots }}"

- name: Provision StorageClasses for all configured tiers
block:
- name: Create StorageClasses on target cluster
Expand Down
Loading
Loading