1

I have problem where managing multiple domains in one top.sls file is getting difficult. How could I write top.sls so that it only takes those pillars that match my minion name/hostname.

For example:

  • There is deplo1.domain1.app minion
  • It loads domain1_app from pillar/domain1_app/init.sls

Current pillar/top.sls

base:
    '*':
        - global
    'system.*':
        - system
    'deploy*.*':
        - deploy

    '*.domain1.app':
        - domain1_app
    deploy0.domain1.app:
        - domain1_app.deploy0
Irfan
  • 3
  • 1

1 Answers1

3

From https://www.reddit.com/r/saltstack/comments/5b4l9v/storing_pillars_specific_to_a_host/ by user "dekonnection":

Put something like this in your pillar's top.sls:

base:
  '*':
  [...stuff that can be shared for multiple hosts defined here...]
  '{{ grains.host }}':
    - ignore_missing: True
    - hosts.{{ grains.host }}

Now you can write a specific <pillar root>/hosts/<hostname>.sls file for host-specific settings for each host that needs them, and if a host does not need anything specific to it, ignore_missing: True allows you to omit the file.

You can do the same using any other grains if necessary.

telcoM
  • 4,153
  • 12
  • 23