|
1 | 1 | --- |
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). |
13 | 4 | - name: Determine pattern dir |
14 | 5 | hosts: localhost |
15 | 6 | connection: local |
16 | 7 | gather_facts: false |
17 | 8 | become: false |
18 | | - vars: |
19 | | - pattern_dir: "{{ lookup('env', 'PATTERN_DIR', default='') }}" |
20 | 9 | 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 |
22 | 16 | ansible.builtin.fail: |
23 | 17 | 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