-
Notifications
You must be signed in to change notification settings - Fork 9
[WIP] Introduce the ability to provision SSCSI roles on hubs and spokes when needed #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mhjacks
wants to merge
29
commits into
validatedpatterns:main
Choose a base branch
from
mhjacks:feature/sscsi-vp-proxy-cluster-ca-chart
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
905212c
vault_utils: SS CSI workload auth from clusterGroup applications
6f41140
fix(vault): resolve SS CSI values path and log workload auth summary
c71b4c4
feat(vault): collect ssCsiWorkloadAuth from managedClusterGroups
d2715e8
fix(vault): resolve pattern_dir for SS CSI without pattern_settings role
a742014
Merge remote-tracking branch 'upstream/main' into feature/sscsi-vault…
1b027fc
Handle naming better
23a4754
fix(vault): honor roleSlug for SS CSI hub/spoke Vault role names
187c184
Merge remote-tracking branch 'upstream/main' into feature/sscsi-vault…
b7265d0
Include some documentation on secrets loading
ef76979
Add CA fetching and injection logic to support SS-CSI workloads
db2bafa
Fix for errors on unseal
cb1a535
Fix linting errors
582cc3d
Fix markdownlint
cd37e5e
Update cluster CA retrieval logic
996bd20
Update to inject PEM
8acafe7
Work with chart provider to inject CA material
1257c2b
Remove CA processing code and fix linter issues
cd6ff40
Add some documentation on how to add elements to clustergroup
7dcf1e7
Fix ansible-lint issues
aa8221a
Expand spoke logic
8af5caf
Pacify super-linter
62c1756
Include fix for runnning in dev mode
dab5ce6
Add extravar handling for pattern_dir if needed
4e4e035
Provide mechanism to discover clustergroup files. Use it to discover …
099f5e1
Update docs
0b2dac3
Remove cluster: key
c75a8f4
Remove unneeded helm-docs make target
0449675
Re-organize ss_csi task files
74657c3
Update docs to reflect task locations
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| { | ||
| "default": true, | ||
| "MD003": false, | ||
| "MD013": false, | ||
| "MD033": false | ||
| } | ||
| "default": true, | ||
| "MD003": false, | ||
| "MD013": { | ||
| "line_length": 400, | ||
| "code_blocks": false, | ||
| "tables": false | ||
| }, | ||
| "MD033": false, | ||
| "MD060": { | ||
| "style": "compact" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| # Discover values-<clustergroup>.yaml|yml under pattern_dir. | ||
| # Resolves pattern_dir like pattern_settings (extra var pattern_dir, env PATTERN_DIR, cwd). | ||
| - name: List pattern clustergroup value stems | ||
| hosts: localhost | ||
| connection: local | ||
| gather_facts: false | ||
| become: false | ||
| roles: | ||
| - pattern_settings | ||
| - role: clustergroup_discovery | ||
| tasks: | ||
| - name: Report clustergroup discovery | ||
| ansible.builtin.debug: | ||
| msg: | ||
| pattern_dir: "{{ pattern_dir }}" | ||
| main_clustergroup: "{{ main_clustergroup }}" | ||
| managed_clustergroup_names: "{{ managed_clustergroup_names }}" | ||
| clustergroup_names: "{{ clustergroup_names }}" | ||
| clustergroup_load_order: "{{ clustergroup_load_order }}" | ||
| clustergroup_file_entries: "{{ clustergroup_file_entries }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --- | ||
| # Parse every top-level values-<clustergroup>.yaml|yml into clustergroup_documents (stem -> root). | ||
| # Use for migration tooling or inspection; SS CSI merge uses the same discovery role internally. | ||
| - name: Parse pattern clustergroup values files | ||
| hosts: localhost | ||
| connection: local | ||
| gather_facts: false | ||
| become: false | ||
| roles: | ||
| - pattern_settings | ||
| - role: clustergroup_discovery | ||
| vars: | ||
| clustergroup_discovery_parse_documents: true | ||
| tasks: | ||
| - name: Summarize parsed clustergroup documents | ||
| ansible.builtin.debug: | ||
| msg: | ||
| pattern_dir: "{{ pattern_dir }}" | ||
| main_clustergroup: "{{ main_clustergroup }}" | ||
| managed_clustergroup_names: "{{ managed_clustergroup_names }}" | ||
| stems_parsed: "{{ clustergroup_documents | default({}) | dict2items | map(attribute='key') | sort | list }}" | ||
| document_count: "{{ clustergroup_documents | default({}) | length }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # clustergroup_discovery | ||
|
|
||
| Ansible role that lists **which clustergroup value stems are in use** for a Validated Patterns checkout, without scanning every `values-*.yaml` on disk. | ||
|
|
||
| ## Behavior | ||
|
|
||
| 1. Resolve **`pattern_dir`** the same way as `pattern_settings` (extra var, `PATTERN_DIR`, then `PWD` / `pwd`). | ||
| 2. Read **`main.clusterGroupName`** from `values-global.yaml` under `pattern_dir` (or use `main_clustergroup` / `main_clustergroupname` if the play already set them). | ||
| 3. Load **`values-<main>.yaml`** or **`values-<main>.yml`** and read **`clusterGroup.managedClusterGroups`**. For each entry, the managed name is **`value.name`** if set, otherwise the **YAML key** (same rule as SS CSI managed-cluster-group defaults). | ||
| 4. Expose facts: | ||
| - **`managed_clustergroup_names`** — sorted unique managed names | ||
| - **`clustergroup_load_order`** — `[main, …managed]` (main first; used when merging so later stems override duplicate `applications` keys) | ||
| - **`clustergroup_names`** — sorted list of all stems (main + managed) | ||
| - **`clustergroup_file_entries`** — `{name, path}` only for stems where a local `values-<stem>.yaml|yml` exists | ||
|
|
||
| Optional: set **`clustergroup_discovery_parse_documents: true`** to fill **`clustergroup_documents`** (`<stem>` → parsed YAML root) for each file in `clustergroup_file_entries`. | ||
|
|
||
| ## Playbooks | ||
|
|
||
| - `playbooks/list_clustergroups.yml` — runs `pattern_settings` + this role and prints the facts above. | ||
| - `playbooks/parse_clustergroup_values.yml` — same with parsing enabled. | ||
|
|
||
| Requires `ANSIBLE_ROLES_PATH` (or collection layout) so `pattern_settings` and this role resolve. | ||
|
|
||
| ## Relation to SS CSI | ||
|
|
||
| `vault_utils` includes this role when **`vault_ss_csi_aggregate_clustergroup_sources`** is true (default): SS CSI then loads and merges **one document per stem** in `clustergroup_load_order`. See `roles/vault_utils/README.md` (SS CSI section) for parsing, extraction, and projection. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| --- | ||
| # When true, slurp and parse each resolved clustergroup file into clustergroup_documents (stem -> root mapping) | ||
| clustergroup_discovery_parse_documents: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| galaxy_info: | ||
| author: rhvp | ||
| description: >- | ||
| Resolve main clustergroup from values-global, read managedClusterGroups from the main | ||
| values file, then optionally parse existing values-<stem> files for those stems. | ||
| license: Apache-2.0 | ||
| min_ansible_version: "2.14" | ||
| galaxy_tags: | ||
| - openshift | ||
| - gitops | ||
| dependencies: [] |
|
mhjacks marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| --- | ||
| # Discover clustergroups in use: main from values-global, managed from main file's clusterGroup.managedClusterGroups. | ||
| # Sets: clustergroup_names (sorted stems), managed_clustergroup_names (sorted, excludes main), | ||
| # clustergroup_load_order (main first, then managed sorted — SS CSI merge precedence), | ||
| # clustergroup_file_entries ({name, path} only when values-<stem>.yaml|yml exists), | ||
| # clustergroup_documents (optional, stem -> parsed YAML root). | ||
|
|
||
| - name: Resolve pattern_dir for clustergroup discovery | ||
| ansible.builtin.include_tasks: ../pattern_settings/tasks/resolve_overrides.yml | ||
| when: (pattern_dir | default('', true) | string | trim | length) == 0 | ||
|
|
||
| - name: Fail when pattern_dir is empty after resolve | ||
| ansible.builtin.fail: | ||
| msg: >- | ||
| pattern_dir is required (extra var pattern_dir, env PATTERN_DIR, or cwd with values-global.yaml). | ||
| when: (pattern_dir | default('', true) | string | trim | length) == 0 | ||
|
|
||
| - name: Resolve main clustergroup stem from facts or values-global.yaml | ||
| ansible.builtin.set_fact: | ||
| _clustergroup_discovery_main_stem: >- | ||
| {{ | ||
| ( | ||
| (main_clustergroupname | default(main_clustergroup | default('', true), true) | string | trim | length) > 0 | ||
| ) | ||
| | ternary( | ||
| main_clustergroupname | default(main_clustergroup, true) | string | trim, | ||
| ( | ||
| lookup('file', (pattern_dir | string | trim) ~ '/values-global.yaml') | ||
| | from_yaml | ||
| ).main.clusterGroupName | string | trim | ||
| ) | ||
| }} | ||
|
|
||
| - name: Fail when main clusterGroupName cannot be resolved | ||
| ansible.builtin.fail: | ||
| msg: >- | ||
| Could not resolve main clustergroup (values-global.yaml missing .main.clusterGroupName or empty). | ||
| when: (_clustergroup_discovery_main_stem | string | trim | length) == 0 | ||
|
|
||
| - name: Stat main clustergroup values file (yaml) | ||
| ansible.builtin.stat: | ||
| path: "{{ pattern_dir | string | trim }}/values-{{ _clustergroup_discovery_main_stem }}.yaml" | ||
| register: _clustergroup_discovery_main_stat_yaml | ||
|
|
||
| - name: Stat main clustergroup values file (yml) | ||
| ansible.builtin.stat: | ||
| path: "{{ pattern_dir | string | trim }}/values-{{ _clustergroup_discovery_main_stem }}.yml" | ||
| register: _clustergroup_discovery_main_stat_yml | ||
| when: not (_clustergroup_discovery_main_stat_yaml.stat.exists | default(false)) | ||
|
|
||
| - name: Set path to main clustergroup values file when present | ||
| ansible.builtin.set_fact: | ||
| _clustergroup_main_values_path: "{{ pattern_dir | string | trim }}/values-{{ _clustergroup_discovery_main_stem }}.yaml" | ||
| when: _clustergroup_discovery_main_stat_yaml.stat.exists | default(false) | ||
|
|
||
| - name: Set path to main clustergroup values file when only yml exists | ||
| ansible.builtin.set_fact: | ||
| _clustergroup_main_values_path: "{{ pattern_dir | string | trim }}/values-{{ _clustergroup_discovery_main_stem }}.yml" | ||
| when: | ||
| - _clustergroup_main_values_path is not defined | ||
| - _clustergroup_discovery_main_stat_yml is defined | ||
| - _clustergroup_discovery_main_stat_yml.stat.exists | default(false) | ||
|
|
||
| - name: Load parsed root from main clustergroup values file | ||
| ansible.builtin.set_fact: | ||
| _clustergroup_main_root: "{{ lookup('file', _clustergroup_main_values_path) | from_yaml }}" | ||
| when: _clustergroup_main_values_path is defined | ||
|
|
||
| - name: Default empty main clustergroup root when file is absent | ||
| ansible.builtin.set_fact: | ||
| _clustergroup_main_root: {} | ||
| when: _clustergroup_main_values_path is not defined | ||
|
|
||
| - name: Collect managed clustergroup names from main file managedClusterGroups | ||
| ansible.builtin.set_fact: | ||
| managed_clustergroup_names: "{{ managed_clustergroup_names | default([]) + [_cgd_mcg_name] }}" | ||
| vars: | ||
| _cgd_mcg_name: "{{ (item.value.name | default(item.key, true)) | string | trim }}" | ||
| loop: "{{ (_clustergroup_main_root.clusterGroup | default({})).managedClusterGroups | default({}) | dict2items }}" | ||
| loop_control: | ||
| label: "{{ _cgd_mcg_name }}" | ||
| when: | ||
| - _clustergroup_main_root is mapping | ||
| - (_clustergroup_main_root.clusterGroup | default({})).managedClusterGroups is defined | ||
| - ((_clustergroup_main_root.clusterGroup | default({})).managedClusterGroups | default({})) is mapping | ||
|
|
||
| - name: Finalize managed clustergroup names list | ||
| ansible.builtin.set_fact: | ||
| managed_clustergroup_names: "{{ managed_clustergroup_names | default([]) | unique | sort }}" | ||
|
|
||
| - name: Set clustergroup load order (main first so managed values files override for SS CSI merge) | ||
| ansible.builtin.set_fact: | ||
| clustergroup_load_order: >- | ||
| {{ | ||
| ( | ||
| [_clustergroup_discovery_main_stem] | ||
| + (managed_clustergroup_names | reject('equalto', _clustergroup_discovery_main_stem) | list) | ||
| ) | unique | list | ||
| }} | ||
|
|
||
| - name: Set sorted clustergroup names (all stems in use) | ||
| ansible.builtin.set_fact: | ||
| clustergroup_names: "{{ clustergroup_load_order | sort }}" | ||
|
|
||
| - name: Build clustergroup_file_entries for stems that have a local values file | ||
| ansible.builtin.include_tasks: resolve_clustergroup_file_path.yml | ||
| loop: "{{ clustergroup_load_order }}" | ||
| loop_control: | ||
| loop_var: clustergroup_discovery_stem | ||
|
|
||
| - name: Default empty clustergroup file entries | ||
| ansible.builtin.set_fact: | ||
| clustergroup_file_entries: [] | ||
| when: clustergroup_file_entries is not defined | ||
|
|
||
| - name: Parse each resolved clustergroup values file when requested | ||
| ansible.builtin.include_tasks: parse_documents.yml | ||
| when: clustergroup_discovery_parse_documents | default(false) | bool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| - name: Parse clustergroup values YAML into clustergroup_documents | ||
| ansible.builtin.set_fact: | ||
| clustergroup_documents: "{{ clustergroup_documents | default({}) | combine({item.name: (lookup('file', item.path) | from_yaml)}) }}" | ||
| loop: "{{ clustergroup_file_entries }}" | ||
| loop_control: | ||
| label: "{{ item.name }}" |
32 changes: 32 additions & 0 deletions
32
roles/clustergroup_discovery/tasks/resolve_clustergroup_file_path.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| # loop_var: clustergroup_discovery_stem — append {name, path} to clustergroup_file_entries when file exists. | ||
|
|
||
| - name: Stat values file for stem {{ clustergroup_discovery_stem }} (yaml) | ||
| ansible.builtin.stat: | ||
| path: "{{ pattern_dir | string | trim }}/values-{{ clustergroup_discovery_stem | string | trim }}.yaml" | ||
| register: _clustergroup_discovery_stem_stat_yaml | ||
|
|
||
| - name: Stat values file for stem {{ clustergroup_discovery_stem }} (yml) | ||
| ansible.builtin.stat: | ||
| path: "{{ pattern_dir | string | trim }}/values-{{ clustergroup_discovery_stem | string | trim }}.yml" | ||
| register: _clustergroup_discovery_stem_stat_yml | ||
|
|
||
| - name: Record clustergroup file entry for {{ clustergroup_discovery_stem }} (prefer yaml) | ||
| ansible.builtin.set_fact: | ||
| clustergroup_file_entries: "{{ clustergroup_file_entries | default([]) + [_entry] }}" | ||
| vars: | ||
| _entry: | ||
| name: "{{ clustergroup_discovery_stem | string | trim }}" | ||
| path: "{{ pattern_dir | string | trim }}/values-{{ clustergroup_discovery_stem | string | trim }}.yaml" | ||
| when: _clustergroup_discovery_stem_stat_yaml.stat.exists | default(false) | ||
|
|
||
| - name: Record clustergroup file entry for {{ clustergroup_discovery_stem }} (yml fallback) | ||
| ansible.builtin.set_fact: | ||
| clustergroup_file_entries: "{{ clustergroup_file_entries | default([]) + [_entry] }}" | ||
| vars: | ||
| _entry: | ||
| name: "{{ clustergroup_discovery_stem | string | trim }}" | ||
| path: "{{ pattern_dir | string | trim }}/values-{{ clustergroup_discovery_stem | string | trim }}.yml" | ||
| when: | ||
| - not (_clustergroup_discovery_stem_stat_yaml.stat.exists | default(false)) | ||
| - _clustergroup_discovery_stem_stat_yml.stat.exists | default(false) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.