Skip to content

Commit 626c1e9

Browse files
Martin Jacksoncursoragent
andcommitted
fix(playbooks): require explicit pattern_dir; drop misleading '.' default
'.' is the ansible-playbook cwd, not the playbook dir; collection installs are not the pattern repo. Accept PATTERN_DIR env or -e pattern_dir and fail with guidance when neither is set. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 81e037a commit 626c1e9

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
---
2-
# pattern_dir may be overridden with -e pattern_dir=/path/to/pattern (extra vars win over this default).
3-
# Default '.' is the usual case when ansible-playbook is run from the pattern repository root.
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.
413
- name: Determine pattern dir
514
hosts: localhost
615
connection: local
716
gather_facts: false
817
become: false
918
vars:
10-
pattern_dir: '.'
19+
pattern_dir: "{{ lookup('env', 'PATTERN_DIR', default='') }}"
1120
tasks:
21+
- name: Fail if pattern directory is not configured
22+
ansible.builtin.fail:
23+
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+
1231
- name: Set pattern_dir fact for future plays
1332
ansible.builtin.set_fact:
1433
pattern_dir: '{{ pattern_dir }}'

0 commit comments

Comments
 (0)