Use variables from different pillar environments in one state

20 views
Skip to first unread message

DD

unread,
Mar 5, 2025, 7:26:53 AMMar 5
to Salt-users
Hi,

I have the following folder structure in my pillar
pillar:
  cut:
    my_test:
      init.sls
  dev:
    my_test:
      init.sls

and i want to use in my state variables from the both (cut a dev) environments.
Something like:
create_file:
  file.managed:
    - name: [salt['pillar.get']([saltenv, 'my_test', 'path']|join(':')), 'file_name']|join('/')
          - defaults: salt['pillar.get']([saltenv, 'my_test', 'var']|join(':'))

The first saltenv is dev, the second saltenv is cut.
As a result I expect a file in /app/dev/file_name with values from cut pillar

Is it possible to do? Is it possible assign environment names dynamically?
Reply all
Reply to author
Forward
0 new messages