Reducing duplication of pillar data

30 views
Skip to first unread message

hashi

unread,
Aug 19, 2016, 5:52:13 AM8/19/16
to Salt-users
Hey all,

Just want to know what everyone is doing around reducing duplication of pillar data for pillars that need to share values? is there any consensus on "best practice"?. So far the only thing I've seen that helps is by creating jinja files and using load_yaml then referencing it in pillar.

Im really not sure how to address such things for example:

2 pillars using same rabbitmq host


/srv/pillar/openstack/cinder.sls
cinder:
  rabbitmq:
    host: 192.168.1.1
    user: admin
    password: blah
    
/srv/pillar/openstack/nova.sls
nova:
  rabbitmq:
    host: 192.168.1.1
    user: admin
    password: blah

Sylvain Viart

unread,
Aug 19, 2016, 7:59:52 AM8/19/16
to salt-...@googlegroups.com
Hi,

Here what I've found:


Le 19/08/2016 à 11:52, hashi a écrit :
Just want to know what everyone is doing around reducing duplication of pillar data for pillars that need to share values? is there any consensus on "best practice"?. So far the only thing I've seen that helps is by creating jinja files and using load_yaml then referencing it in pillar.

Same approach for me:

{% import_yaml "/srv/salt/pillar/auto/managed_password.yaml" as pass with context %}
mysql:
  user:
    user1:
      password: "{{ pass['user1']['mysql'] }}"

So I decided to generate pillar…
https://github.com/opensource-expert/customers-formula/



2 pillars using same rabbitmq host


/srv/pillar/openstack/cinder.sls
cinder:
  rabbitmq:
    host: 192.168.1.1
    user: admin
    password: blah
    
/srv/pillar/openstack/nova.sls
nova:
  rabbitmq:
    host: 192.168.1.1
    user: admin
    password: blah

or you could loop or use macro in jinja, if you did in some formula, there is many loop in state.


{% for h in salt['pillar.get']('mykey:rabbitmq', {}).itemps() %}
/srv/pillar/openstack/{{ h }}.sls
{{ h }}:
  rabbitmq:
    host: 192.168.1.1
    user: admin
    password: blah
{% endfor %}


Regards,
Sylvain.
-- 
Sylvain Viart - Consultant informatique système linux
Reply all
Reply to author
Forward
0 new messages