On 2 Jul 2018, at 16:00, Eric Veiras Galisson wrote:
Pillarstack loading of data follows this logic:
step 1) load all common values from '*main repo*'
step 2) load environment specific data from '*main repo*'
step 3) load host specific data from '*host repo*'
step 4) load more data (we name it '*post_include*') from '*main
repo*' depending
of previous host specific data -> this is part of the 'pillar in pillar'
need we have, and the tricky part.
This is our setup but don't describe our objectives:
Hi Eric,
I think I’ve got something quite similar to what you’re after. The difference being that I’ve been able to get here without pillarstack (I’m still planning to look at it for other reasons though). I’ll explain a bit what I’ve got where with inline replies.
1. we want to have in our '*main repo*' all our common infrastructure and
logic
I’ve got a separate git repo that has all my formulas. This is pretty much exactly like the formulas that you can find here https://github.com/saltstack-formulas
The only thing to note is that my repo is being used over GitFS from my salt master. The beauty is that you have all default settings together with your formulas inside your defaults.yaml.
2. we want to have host specific data in our '*host repo*' which is managed
by another team responsible for day-to-day servers operations
My server specific settings are in a subdir in my pillar repo. I include a specific file with the minion specific variables variables by doing a small trick in my pillar top.sls which is this:
'*':
# translate the "." in the minionid to "_"
- server_vars.{{ grains['id']|replace('.', '_') }}
In this folder called server_vars there are files that match the minion id with - and dots translated to _ because you are not allowed to have - in state filenames. for example hostname_example_com.sls
3. we want to be able to define '*services*' in our host pillar
Inside my state top.sls I’ve used pillar PCRE targeting to apply certains formulas to minions that have a certain pillar value set. It goes something like this:
My pillar:server_vars/some_host.sls has this:
# What services are allowed on this machine
services:
tomcat: True
ssl-certs: True
And my state top.sls has this:
base:
'J@services:tomcat':
- tomcat
'J@services:ssl-certs':
- ssl-certs
p.s. You could make service in my pillar a yaml list instead of booleans /shrug…
4. we want to allow possibility of adding config data or overriding config
data in the host pillar
That’s what the map.jinja takes care of that you should have in each of your formulas from point 1. In combination with importing the result from your map.jinja everywhere. See the import statements at the top of most .sls files in the fomulas on github.
Good luck!
Sjoerd Oostdijck
Senior Systems Engineer - RIPE NCC
On 2 Jul 2018, at 16:00, Eric Veiras Galisson wrote:
Pillarstack loading of data follows this logic:
step 1) load all common values from '*main repo*'
step 2) load environment specific data from '*main repo*'
step 3) load host specific data from '*host repo*'
step 4) load more data (we name it '*post_include*') from '*main
repo*' depending
of previous host specific data -> this is part of the 'pillar in pillar'
need we have, and the tricky part.
This is our setup but don't describe our objectives:Hi Eric,
I think I’ve got something quite similar to what you’re after. The difference being that I’ve been able to get here without pillarstack (I’m still planning to look at it for other reasons though). I’ll explain a bit what I’ve got where with inline replies.
1. we want to have in our '*main repo*' all our common infrastructure and
logicI’ve got a separate git repo that has all my formulas. This is pretty much exactly like the formulas that you can find here https://github.com/saltstack-formulas
The only thing to note is that my repo is being used over GitFS from my salt master. The beauty is that you have all default settings together with your formulas inside your defaults.yaml.2. we want to have host specific data in our '*host repo*' which is managed
by another team responsible for day-to-day servers operationsMy server specific settings are in a subdir in my pillar repo. I include a specific file with the minion specific variables variables by doing a small trick in my pillar
top.slswhich is this:'*': # translate the "." in the minionid to "_" - server_vars.{{ grains['id']|replace('.', '_') }}In this folder called
server_varsthere are files that match the minion id with - and dots translated to _ because you are not allowed to have - in state filenames. for example hostname_example_com.sls
3. we want to be able to define '*services*' in our host pillar
Inside my state top.sls I’ve used pillar PCRE targeting to apply certains formulas to minions that have a certain pillar value set. It goes something like this:
My pillar:server_vars/some_host.sls has this:
# What services are allowed on this machine services: tomcat: True ssl-certs: TrueAnd my state top.sls has this:
base: 'J@services:tomcat': - tomcat 'J@services:ssl-certs': - ssl-certsp.s. You could make service in my pillar a yaml list instead of booleans /shrug…
4. we want to allow possibility of adding config data or overriding config
data in the host pillar
That’s what the
map.jinjatakes care of that you should have in each of your formulas from point 1. In combination with importing the result from your map.jinja everywhere. See the import statements at the top of most .sls files in the fomulas on github.
Good luck!
include is macros that skips absent state files for older saltstack releses:
{%- macro include(path) -%}
{%- set includes = [] -%}
{%- if salt['cp.list_master'](prefix=path) -%}
{%- set inc = path.replace('/','.') + '.*' %}
{%- if inc not in includes -%}
{%- do includes.append(inc) -%}
{%- endif -%}
{%- endif -%}
{%- for inc in includes -%}
- {{ inc }}
{%- endfor -%}
{%- endmacro -%}
keepalived_vip_virtual_router_id: 180keepalived_vip_password: ${_param:cicd_keepalived_vip_password_generated}keepalived_vip_interface: ens3cluster_vip_address: ${_param:control_vip_address}control_vip_address: ${_param:cicd_control_address}