-
Hello, I don't understand how "names" work. The docs https://docs.saltproject.io/en/latest/ref/states/highstate.html#names-declaration claims that this state:
will be converted to:
But when I check the lowstate I see states with the same IDs:
But the docs says that you can't have two states with same IDs! So how does this work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I think you're pointing out an oversimplification in the docs. In general, duplicate state IDs are disallowed in the highstate data structure because it's a mapping, where duplicate keys would necessarily overwrite each other (and, if defined in the same SLS, be unrepresentable). The Lines 676 to 692 in 9233e1c A more accurate simplification: For each This cannot be communicated properly using the YAML representation of the highstate because it's invalid: Note: The referenced example state using unwanted-files:
file.absent:
- names:
- /foo
- /bar
- /baz => (highstate, invalid YAML/data structure) unwanted-files:
file.absent:
- name: /foo
unwanted-files:
file.absent:
- name: /bar
unwanted-files:
file.absent:
- name: /baz (simplified lowstate, valid YAML/data structure) - id: unwanted-files
name: /foo
state: file
fun: absent
- id: unwanted-files
name: /bar
state: file
fun: absent
- id: unwanted-files
name: /baz
state: file
fun: absent |
Beta Was this translation helpful? Give feedback.
I think you're pointing out an oversimplification in the docs.
In general, duplicate state IDs are disallowed in the highstate data structure because it's a mapping, where duplicate keys would necessarily overwrite each other (and, if defined in the same SLS, be unrepresentable).
The
names
parameter influences the state compiler (which compiles the highstate data structure into lowstate chunks), specifically here:salt/salt/state.py
Lines 676 to 692 in 9233e1c