SuperTux88's Diaspora Saltstack Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2KB

  1. {% set pkg = salt['grains.filter_by']({
  2. 'Debian': 'postgresql',
  3. 'RedHat': 'postgresql-server',
  4. 'Arch': 'postgresql',
  5. }) -%}
  6. pgsql_package:
  7. pkg.installed:
  8. - name: {{ pkg }}
  9. {%- if grains.os_family == 'RedHat' %}
  10. pgsql_initdb_redhat:
  11. cmd.run:
  12. - name: postgresql-setup initdb
  13. - require:
  14. - pkg: pgsql_package
  15. pgsql_pg_hba_redhat:
  16. file.replace:
  17. - name: /var/lib/pgsql/data/pg_hba.conf
  18. - pattern: ' ident'
  19. - repl: ' md5'
  20. - require:
  21. - cmd: pgsql_initdb_redhat
  22. - require_in:
  23. - service: pgsql_service
  24. {%- elif grains.os_family == 'Arch' %}
  25. pgsql_initdb_arch:
  26. cmd.run:
  27. - name: initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'
  28. - runas: postgres
  29. - require:
  30. - pkg: pgsql_package
  31. - require_in:
  32. - service: pgsql_service
  33. {%- endif %}
  34. pgsql_service:
  35. service.running:
  36. - name: postgresql
  37. - require:
  38. - pkg: pgsql_package
  39. pgsql_user:
  40. postgres_user.present:
  41. - name: {{ salt['pillar.get']('diaspora:database:username') }}
  42. - password: {{ salt['pillar.get']('diaspora:database:password') }}
  43. - createdb: True
  44. - require:
  45. - service: pgsql_service
  46. - require_in:
  47. - cmd: diaspora_create_database