Lets take an example of what I have today: https://gist.github.com/Natim/6548009
I use the pillar to create a database and a user. It works fine on server with one of the roles but if I need both roles on the same server only the last pillar is taken into account.
How can I create my pillar and salt so that a salt is create for each role?
I could do something like that:
{% for db in pillar['dbs'] %}
postgresql_db_{{ db['postgresql_db_name'] }}:
postgres_database.present:
- name: {{ db['postgresql_db_name'] }}
- owner: {{ db['postgresql_db_user'] }}
- encoding: UTF8
- lc_ctype: en_US.UTF8
- lc_collate: en_US.UTF8
- template: template0
- runas: postgres
- require:
- service: postgresql
- postgres_user: postgresql_user_{{ db['postgresql_db_user'] }}
postgresql_user_{{ db['postgresql_db_user'] }}:
postgres_user.present:
- name: {{ db['postgresql_db_user'] }}
- password: {{ db['postgresql_db_password'] }}
- require:
- service: postgresql
{% endfor %}
But then how to populate the pillar['dbs']
with two files?
Thanks
I finally managed to do what I wanted.
Here is my solution:
pillar
They can be in different files.
salt
Then create your salt like this:
The important thing is this :
This let you define many pillars that will be taken into account without overriding other.
Interesting article: http://dev.mlsdigital.net/posts/SaltStackBeyondJinjaStates/
Many thanks to brutasse for the help.