Browse Source

test(postgres): install postgres for tests

tags/v1.0.0
Benjamin Neff 4 years ago
parent
commit
c2b6e4314f
No account linked to committer's email address
2 changed files with 44 additions and 0 deletions
  1. +3
    -0
      kitchen.yml
  2. +41
    -0
      test/salt/states/postgres/init.sls

+ 3
- 0
kitchen.yml View File

- diaspora._mapdata - diaspora._mapdata
- diaspora - diaspora
- redis - redis
- postgres
pillars: pillars:
top.sls: top.sls:
base: base:
dependencies: dependencies:
- name: redis - name: redis
path: test/salt/states path: test/salt/states
- name: postgres
path: test/salt/states
verifier: verifier:
inspec_tests: inspec_tests:
- path: test/integration/_mapdata - path: test/integration/_mapdata

+ 41
- 0
test/salt/states/postgres/init.sls View File

{% 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

Loading…
Cancel
Save