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:
|
postgres:
|
||||||
pg_hba.conf: salt://postgres/pg_hba.conf
|
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
|
use_upstream_repo: False
|
||||||
|
|
||||||
pkg: 'postgresql-9.3'
|
pkg: 'postgresql-9.3'
|
||||||
|
@ -50,12 +43,13 @@ postgres:
|
||||||
- ['host', 'db2', 'remoteUser', '123.123.0.0/24']
|
- ['host', 'db2', 'remoteUser', '123.123.0.0/24']
|
||||||
|
|
||||||
tablespaces:
|
tablespaces:
|
||||||
my_space: /srv/my_tablespace
|
my_space:
|
||||||
|
directory: /srv/my_tablespace
|
||||||
|
owner: localUser
|
||||||
|
|
||||||
databases:
|
databases:
|
||||||
db1:
|
db1:
|
||||||
owner: 'localUser'
|
owner: 'localUser'
|
||||||
user: 'localUser'
|
|
||||||
template: 'template0'
|
template: 'template0'
|
||||||
lc_ctype: 'en_US.UTF-8'
|
lc_ctype: 'en_US.UTF-8'
|
||||||
lc_collate: 'en_US.UTF-8'
|
lc_collate: 'en_US.UTF-8'
|
||||||
|
|
|
@ -3,7 +3,6 @@ postgres:
|
||||||
pkg_dev: postgresql-devel
|
pkg_dev: postgresql-devel
|
||||||
pkg_libpq_dev: postgresql-libs
|
pkg_libpq_dev: postgresql-libs
|
||||||
pkg_client: postgresql-client
|
pkg_client: postgresql-client
|
||||||
pkgs_extra:
|
|
||||||
python: python-psycopg2
|
python: python-psycopg2
|
||||||
service: postgresql
|
service: postgresql
|
||||||
conf_dir: /var/lib/pgsql/data
|
conf_dir: /var/lib/pgsql/data
|
||||||
|
|
|
@ -48,9 +48,11 @@ postgresql-running:
|
||||||
- cmd: postgresql-cluster-prepared
|
- cmd: postgresql-cluster-prepared
|
||||||
|
|
||||||
{% if postgres.pkgs_extra %}
|
{% if postgres.pkgs_extra %}
|
||||||
postgresql-extra-pkgs-installed:
|
{% for pkg in postgres.pkgs_extra %}
|
||||||
|
postgresql-extra-pkgs-installed_{{ pkg }}:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- pkgs: {{ postgres.pkgs_extra }}
|
- name: {{ pkg }}
|
||||||
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if postgres.postgresconf %}
|
{% if postgres.postgresconf %}
|
||||||
|
@ -132,8 +134,17 @@ postgresql-tablespace-{{ name }}:
|
||||||
- name: {{ name }}
|
- name: {{ name }}
|
||||||
- directory: {{ tblspace.directory }}
|
- directory: {{ tblspace.directory }}
|
||||||
- user: {{ tblspace.get('runas', postgres.user) }}
|
- user: {{ tblspace.get('runas', postgres.user) }}
|
||||||
{% if tblspace.get('user') %}
|
{% if tblspace.get('db_user') %}
|
||||||
- db_user: {{ tblspace.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 %}
|
{% endif %}
|
||||||
{% if tblspace.get('owner') %}
|
{% if tblspace.get('owner') %}
|
||||||
- owner: {{ tblspace.owner }}
|
- owner: {{ tblspace.owner }}
|
||||||
|
@ -172,8 +183,17 @@ postgresql-db-{{ name }}:
|
||||||
- owner: {{ db.owner }}
|
- owner: {{ db.owner }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
- user: {{ db.get('runas', postgres.user) }}
|
- user: {{ db.get('runas', postgres.user) }}
|
||||||
{% if db.get('user') %}
|
{% if db.get('db_user') %}
|
||||||
- db_user: {{ 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 %}
|
{% endif %}
|
||||||
- require:
|
- require:
|
||||||
- service: postgresql-running
|
- service: postgresql-running
|
||||||
|
@ -184,7 +204,7 @@ postgresql-db-{{ name }}:
|
||||||
- postgres_user: postgresql-user-{{ db.owner }}
|
- postgres_user: postgresql-user-{{ db.owner }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if db.get('tablespace') %}
|
{% if db.get('tablespace') %}
|
||||||
- postgres_tablespace: postgresql-tablespace-{{ name }}
|
- postgres_tablespace: postgresql-tablespace-{{ db.get('tablespace') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# NOTE: postgres_schema doesn't have a 'runas' equiv. at all #}
|
{# 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 }}
|
- postgres_user: postgresql-user-{{ ext.user }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if ext.get('schema') %}
|
{% if ext.get('schema') %}
|
||||||
- postgres_schema: postgresql-schema-{{ ext.schema }}
|
- postgres_schema: postgresql-schema-{{ ext.schema }}-for-db-{{ name }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
require 'serverspec'
|
require 'serverspec'
|
||||||
|
|
||||||
|
set :backend, :exec
|
||||||
|
|
||||||
describe service('postgresql') do
|
describe service('postgresql') do
|
||||||
it { should be_enabled }
|
it { should be_enabled }
|
||||||
it { should be_running }
|
it { should be_running }
|
||||||
|
@ -16,6 +18,6 @@ describe file('/srv/my_tablespace') do
|
||||||
it { should be_grouped_into 'postgres' }
|
it { should be_grouped_into 'postgres' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe command('su - postgres -c "psql -qtc \"\l+ db2\""') do
|
describe command(%q{su - postgres -c 'psql -qtc "\l+ db2"'}) do
|
||||||
its(:stdout) { should match(/db2.*localUser.*UTF8.*C.UTF-8.*C.UTF-8.*my_space/) }
|
its(:stdout) { should match(/db2.*localUser.*UTF8.*en_US\.UTF-8.*en_US\.UTF-8.*my_space/) }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue