Skip to content

Commit

Permalink
test(postgres): install postgres for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperTux88 committed Oct 11, 2020
1 parent a8d08ff commit c2b6e43
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ suites:
- diaspora._mapdata
- diaspora
- redis
- postgres
pillars:
top.sls:
base:
Expand All @@ -207,6 +208,8 @@ suites:
dependencies:
- name: redis
path: test/salt/states
- name: postgres
path: test/salt/states
verifier:
inspec_tests:
- path: test/integration/_mapdata
Expand Down
41 changes: 41 additions & 0 deletions test/salt/states/postgres/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% set pkg = salt['grains.filter_by']({
'Debian': 'postgresql',
'RedHat': 'postgresql-server',
}) -%}

pgsql_package:
pkg.installed:
- name: {{ pkg }}

{%- if grains.os_family == 'RedHat' %}
pgsql_initdb:
cmd.run:
- name: postgresql-setup initdb
- require:
- pkg: pgsql_package
pgsql_pg_hba_redhat:
file.replace:
- name: /var/lib/pgsql/data/pg_hba.conf
- pattern: ' ident'
- repl: ' md5'
- require:
- cmd: pgsql_initdb_redhat
- require_in:
- service: pgsql_service
{%- endif %}

pgsql_service:
service.running:
- name: postgresql
- require:
- pkg: pgsql_package

pgsql_user:
postgres_user.present:
- name: {{ salt['pillar.get']('diaspora:database:username') }}
- password: {{ salt['pillar.get']('diaspora:database:password') }}
- createdb: True
- require:
- service: pgsql_service
- require_in:
- cmd: diaspora_create_database

0 comments on commit c2b6e43

Please sign in to comment.