Skip to content

Commit b3032d6

Browse files
Martin Jacksoncursoragent
andcommitted
fix(playbooks): resolve pattern_dir like pattern_settings
Reuse pattern_settings resolve_overrides (extra var, PATTERN_DIR, PWD, pwd) so determine_pattern_dir matches list_clustergroups and README; fail only if still empty after that chain. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 626c1e9 commit b3032d6

1 file changed

Lines changed: 11 additions & 24 deletions

File tree

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,20 @@
11
---
2-
# Root of the Validated Pattern checkout (directory that contains values-global.yaml, values-secret.yaml, etc.).
3-
#
4-
# Set explicitly; this is NOT inferred from the playbook file path when you run collection playbooks from
5-
# ~/.ansible/collections/... — and a literal '.' would mean the shell's current working directory, not the pattern repo.
6-
#
7-
# Configure either:
8-
# ansible-playbook .../display_secrets_info.yml -e pattern_dir=/absolute/path/to/pattern
9-
# or:
10-
# export PATTERN_DIR=/absolute/path/to/pattern
11-
#
12-
# Extra vars (-e pattern_dir) take precedence over PATTERN_DIR when both are set.
2+
# Same resolution as roles/pattern_settings/tasks/resolve_overrides.yml and README.md:
3+
# extra var pattern_dir, then env PATTERN_DIR, then env PWD, then output of pwd (trimmed).
134
- name: Determine pattern dir
145
hosts: localhost
156
connection: local
167
gather_facts: false
178
become: false
18-
vars:
19-
pattern_dir: "{{ lookup('env', 'PATTERN_DIR', default='') }}"
209
tasks:
21-
- name: Fail if pattern directory is not configured
10+
- name: Resolve pattern_dir (same as pattern_settings)
11+
ansible.builtin.include_role:
12+
name: pattern_settings
13+
tasks_from: resolve_overrides
14+
15+
- name: Fail if pattern_dir is still empty after resolution
2216
ansible.builtin.fail:
2317
msg: >-
24-
pattern_dir is not set. Pass your pattern repository root (absolute path), e.g.
25-
ansible-playbook .../display_secrets_info.yml -e pattern_dir=/path/to/pattern
26-
or set environment variable PATTERN_DIR to that path before running.
27-
A default of '.' would follow the shell's current working directory, not the playbook
28-
directory, and is not used here to avoid loading the wrong values-global.yaml.
29-
when: pattern_dir | length == 0
30-
31-
- name: Set pattern_dir fact for future plays
32-
ansible.builtin.set_fact:
33-
pattern_dir: '{{ pattern_dir }}'
18+
Could not resolve pattern_dir. Set -e pattern_dir=/path/to/pattern, export PATTERN_DIR,
19+
or run from your pattern repository so PWD / pwd points at the directory that contains values-global.yaml.
20+
when: pattern_dir | default('', true) | string | trim | length == 0

0 commit comments

Comments
 (0)