mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 09:40:26 +00:00
Merge pull request #114 from fortune-juggle/fix/specs
fixes formula to comply to its spec
This commit is contained in:
commit
761014ec47
4 changed files with 35 additions and 20 deletions
|
@ -1,12 +1,5 @@
|
|||
postgres:
|
||||
pg_hba.conf: salt://postgres/pg_hba.conf
|
||||
prepare_cluster:
|
||||
user: root
|
||||
command: service postgresql initdb
|
||||
test: test -f /path/to/some/file
|
||||
env:
|
||||
LC_ALL: en_US.UTF-8
|
||||
|
||||
use_upstream_repo: False
|
||||
|
||||
pkg: 'postgresql-9.3'
|
||||
|
@ -50,12 +43,13 @@ postgres:
|
|||
- ['host', 'db2', 'remoteUser', '123.123.0.0/24']
|
||||
|
||||
tablespaces:
|
||||
my_space: /srv/my_tablespace
|
||||
my_space:
|
||||
directory: /srv/my_tablespace
|
||||
owner: localUser
|
||||
|
||||
databases:
|
||||
db1:
|
||||
owner: 'localUser'
|
||||
user: 'localUser'
|
||||
template: 'template0'
|
||||
lc_ctype: 'en_US.UTF-8'
|
||||
lc_collate: 'en_US.UTF-8'
|
||||
|
|
|
@ -3,7 +3,6 @@ postgres:
|
|||
pkg_dev: postgresql-devel
|
||||
pkg_libpq_dev: postgresql-libs
|
||||
pkg_client: postgresql-client
|
||||
pkgs_extra:
|
||||
python: python-psycopg2
|
||||
service: postgresql
|
||||
conf_dir: /var/lib/pgsql/data
|
||||
|
|
|
@ -48,9 +48,11 @@ postgresql-running:
|
|||
- cmd: postgresql-cluster-prepared
|
||||
|
||||
{% if postgres.pkgs_extra %}
|
||||
postgresql-extra-pkgs-installed:
|
||||
{% for pkg in postgres.pkgs_extra %}
|
||||
postgresql-extra-pkgs-installed_{{ pkg }}:
|
||||
pkg.installed:
|
||||
- pkgs: {{ postgres.pkgs_extra }}
|
||||
- name: {{ pkg }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if postgres.postgresconf %}
|
||||
|
@ -132,8 +134,17 @@ postgresql-tablespace-{{ name }}:
|
|||
- name: {{ name }}
|
||||
- directory: {{ tblspace.directory }}
|
||||
- user: {{ tblspace.get('runas', postgres.user) }}
|
||||
{% if tblspace.get('user') %}
|
||||
- db_user: {{ tblspace.user }}
|
||||
{% if tblspace.get('db_user') %}
|
||||
- db_user: {{ tblspace.db_user }}
|
||||
{% endif %}
|
||||
{% if tblspace.get('db_password') %}
|
||||
- db_password: {{ tblspace.db_password }}
|
||||
{% endif %}
|
||||
{% if tblspace.get('db_host') %}
|
||||
- db_host: {{ tblspace.db_host }}
|
||||
{% endif %}
|
||||
{% if tblspace.get('db_port') %}
|
||||
- db_port: {{ tblspace.db_port }}
|
||||
{% endif %}
|
||||
{% if tblspace.get('owner') %}
|
||||
- owner: {{ tblspace.owner }}
|
||||
|
@ -172,8 +183,17 @@ postgresql-db-{{ name }}:
|
|||
- owner: {{ db.owner }}
|
||||
{% endif %}
|
||||
- user: {{ db.get('runas', postgres.user) }}
|
||||
{% if db.get('user') %}
|
||||
- db_user: {{ db.user }}
|
||||
{% if db.get('db_user') %}
|
||||
- db_user: {{ db.db_user }}
|
||||
{% endif %}
|
||||
{% if db.get('db_password') %}
|
||||
- db_password: {{ db.db_password }}
|
||||
{% endif %}
|
||||
{% if db.get('db_host') %}
|
||||
- db_host: {{ db.db_host }}
|
||||
{% endif %}
|
||||
{% if db.get('db_port') %}
|
||||
- db_port: {{ db.db_port }}
|
||||
{% endif %}
|
||||
- require:
|
||||
- service: postgresql-running
|
||||
|
@ -184,7 +204,7 @@ postgresql-db-{{ name }}:
|
|||
- postgres_user: postgresql-user-{{ db.owner }}
|
||||
{% endif %}
|
||||
{% if db.get('tablespace') %}
|
||||
- postgres_tablespace: postgresql-tablespace-{{ name }}
|
||||
- postgres_tablespace: postgresql-tablespace-{{ db.get('tablespace') }}
|
||||
{% endif %}
|
||||
|
||||
{# NOTE: postgres_schema doesn't have a 'runas' equiv. at all #}
|
||||
|
@ -252,7 +272,7 @@ postgresql-ext-{{ ext_name }}-for-db-{{ name }}:
|
|||
- postgres_user: postgresql-user-{{ ext.user }}
|
||||
{% endif %}
|
||||
{% if ext.get('schema') %}
|
||||
- postgres_schema: postgresql-schema-{{ ext.schema }}
|
||||
- postgres_schema: postgresql-schema-{{ ext.schema }}-for-db-{{ name }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
require 'serverspec'
|
||||
|
||||
set :backend, :exec
|
||||
|
||||
describe service('postgresql') do
|
||||
it { should be_enabled }
|
||||
it { should be_running }
|
||||
|
@ -16,6 +18,6 @@ describe file('/srv/my_tablespace') do
|
|||
it { should be_grouped_into 'postgres' }
|
||||
end
|
||||
|
||||
describe command('su - postgres -c "psql -qtc \"\l+ db2\""') do
|
||||
its(:stdout) { should match(/db2.*localUser.*UTF8.*C.UTF-8.*C.UTF-8.*my_space/) }
|
||||
describe command(%q{su - postgres -c 'psql -qtc "\l+ db2"'}) do
|
||||
its(:stdout) { should match(/db2.*localUser.*UTF8.*en_US\.UTF-8.*en_US\.UTF-8.*my_space/) }
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue