Created
September 13, 2013 08:19
-
-
Save Natim/6548009 to your computer and use it in GitHub Desktop.
I have roles that needs to create each a postgres role and a postgres database. I would like to use the magic of saltstack to do that.
Lets say my roles are peopleask and novaauth. How to make it work when both roles are on the same server?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgresql_db_user: novaauth | |
postgresql_db_password: novaauth | |
postgresql_db_name: novaauth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgresql_db_user: peopleask | |
postgresql_db_password: peopleask | |
postgresql_db_name: peopleask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base: | |
'roles:peopleask': | |
- match: grain | |
- peopleask.db | |
'roles:novaauth': | |
- match: grain | |
- novaauth.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgresql: | |
pkg: | |
- name: postgresql-9.1 | |
- installed | |
service.running: | |
- enable: True | |
postgresql_db_{{ pillar['postgresql_db_name'] }}: | |
postgres_database.present: | |
- name: {{ pillar['postgresql_db_name'] }} | |
- owner: {{ pillar['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_{{ pillar['postgresql_db_user'] }} | |
postgresql_user_{{ pillar['postgresql_db_user'] }}: | |
postgres_user.present: | |
- name: {{ pillar['postgresql_db_user'] }} | |
- password: {{ pillar['postgresql_db_password'] }} | |
- require: | |
- service: postgresql | |
postgresql.conf: | |
file.append: | |
- name: /etc/postgresql/9.1/main/postgresql.conf | |
- text: "listen_addresses = '*'" | |
- require: | |
- pkg: postgresql | |
- watch_in: | |
- service: postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base: | |
'G@roles:peopleask and G@roles:postgresql': | |
- match: compound | |
- postgresql | |
'G@roles:novaauth and G@roles:postgresql': | |
- match: compound | |
- postgresql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment