Answers: <p>The "saltey" way of doing this is typically in a map.jinja file. <a href="https://github.com/jdshewey/salt-formula-freeipa/blob/master/freeipa/map.jinja" rel="nofollow noreferrer">This one</a> for example...</p>
  
  <p>In that, you would:</p>
  
  <pre><code>{%- load_yaml as serverlist %}
  #Note that a default list could be provided here
  {%- endload %}
  
  {%- set serverlist2 = salt['grains.filter_by'](serverlist, merge=salt['pillar.get']('pillarname:server_list_de')) %}
  {%- set servers = salt['grains.filter_by'](serverlist2, merge=salt['pillar.get']('pillarname:server_list_uk')) %}
  </code></pre>
  
  <p>Then in your sls file you would then put at the top:</p>
  
  <pre><code>{%- from "formulaname/map.jinja" import servers with context %}
  </code></pre>
  
  <p>Servers should then be available to you. I've never tried merging twice though, so give it a try. At a minimum this may give you some direction as the syntax for doing a pillar merge like this may get you what you are looking for.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-01-30T16:39:39.827Z
Answers: 2019-01-30T16:39:39.827Z
Answers: James Shewey
Body: <p>I have a several pillars and I am trying to merge them in the same jinja variable</p>
  
  <pre><code>{%- import_yaml "server_list_de.yaml" as servers %}
  {%- import_yaml "server_list_uk.yaml" as servers_uk %}
  {%- servers.update(servers_uk) %}
  </code></pre>
  
  <p>but I've got following error:</p>
  
  <pre><code>File "/usr/lib/python2.7/dist-packages/salt/utils/context.py", line 211, in __getitem__
  return self._dict()[key]
  KeyError: '_errors'
  </code></pre>
  
Tags: <salt><jinja>
Title: Saltstack Jinja template pillar merge
UserDisplayName: BlackBishop
ThreadText: # Saltstack Jinja template pillar merge
  
  (Asked by: username_0 on 2019-01-26)
  
  I have a several pillars and I am trying to merge them in the same jinja variable
  
  ```
  {%- import_yaml "server_list_de.yaml" as servers %}
  {%- import_yaml "server_list_uk.yaml" as servers_uk %}
  {%- servers.update(servers_uk) %}
  
  ```
  
  but I've got following error:
  
  ```
  File "/usr/lib/python2.7/dist-packages/salt/utils/context.py", line 211, in __getitem__
  return self._dict()[key]
  KeyError: '_errors'
  
  ```
  
  **Tags:** salt, jinja
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-01-30. Score: 1
  
  The "saltey" way of doing this is typically in a map.jinja file. [This one](https://github.com/jdshewey/salt-formula-freeipa/blob/master/freeipa/map.jinja) for example...
  
  In that, you would:
  
  ```
  {%- load_yaml as serverlist %}
  #Note that a default list could be provided here
  {%- endload %}
  
  {%- set serverlist2 = salt['grains.filter_by'](serverlist, merge=salt['pillar.get']('pillarname:server_list_de')) %}
  {%- set servers = salt['grains.filter_by'](serverlist2, merge=salt['pillar.get']('pillarname:server_list_uk')) %}
  
  ```
  
  Then in your sls file you would then put at the top:
  
  ```
  {%- from "formulaname/map.jinja" import servers with context %}
  
  ```
  
  Servers should then be available to you. I've never tried merging twice though, so give it a try. At a minimum this may give you some direction as the syntax for doing a pillar merge like this may get you what you are looking for.
  
  
  ---
  
  