melvil james
melvil james

Reputation: 611

How can i add dynamic values in salt pillars?

Suppose that my pillar value depends on the part of the hostname and based on that string i want to specify pillar values for my jinja template.

#/srv/pillar/managefiles.sls 
pkg: 
  heap: 30

Upvotes: 0

Views: 1986

Answers (1)

ahus1
ahus1

Reputation: 5932

In a scenario with a production systems with big heaps, and a test system with small heaps it could look like this:

#/srv/pillar/top.sls
base:
  '*prod':
    - managefiles_prod
  '*test':
    - managefiles_test

with the pillars

#/srv/pillar/managefiles_prod.sls 
pkg: 
  heap: 30

and

#/srv/pillar/managefiles_test.sls 
pkg: 
  heap: 10

The pattern in the top.sls file will pick a different pillar file depending on the host name: all host names ending with prod will receive production settings, all host names ending with test will receive test settings. See the top file documentation and matching with grains for more information.

Upvotes: 3

Related Questions