-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path08-loops-demo.yaml
More file actions
59 lines (53 loc) · 1.49 KB
/
08-loops-demo.yaml
File metadata and controls
59 lines (53 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Loop Observations Example
#
# This profile demonstrates:
# - loop: Iterate observations over a list from vars
# - Each item is accessible via {{ .loop.item }}
# - Custom variable names with the 'as' field
#
# Run with: ./bin/reglet check docs/examples/08-loops-demo.yaml --trust-plugins
profile:
name: Loop Observations Demo
description: Demonstrates loop functionality for observations
version: 1.0.0
plugins:
- file
vars:
# Simple list of file paths
config_files:
- /etc/passwd
- /etc/group
- /etc/hosts
# More complex items with properties
services:
- name: ssh-config
path: /etc/ssh/sshd_config
- name: resolv
path: /etc/resolv.conf
controls:
items:
# Simple loop over list of strings
- id: config-files-exist
name: Config Files Exist
description: Check that all config files exist using loop
observations:
- loop:
items: "{{ .vars.config_files }}"
plugin: file
config:
path: "{{ .loop.item }}"
expect:
- data.exists == true
# Loop with custom variable name for object properties
- id: service-configs-exist
name: Service Config Files Exist
description: Check service configuration files using custom loop variable
observations:
- loop:
items: "{{ .vars.services }}"
as: svc
plugin: file
config:
path: "{{ .svc.path }}"
expect:
- data.exists == true