Skip to content

Commit

Permalink
fix(pgsql): do not try to create db and user with schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ghormoon committed May 6, 2021
1 parent 5c81ca1 commit 058a800
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 33 deletions.
9 changes: 7 additions & 2 deletions docs/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,20 @@ Creates database and mysql user for Zabbix.

Creates mysql schema for Zabbix.

``zabbix.pgsql.pkgs``
^^^^^^^^^^^^^^^^^^^^^^^

Install required psql packages.

``zabbix.pgsql.conf``
^^^^^^^^^^^^^^^^^^^^^

Creates database and PostgreSQL user for Zabbix.
Creates database and PostgreSQL user for Zabbix. Includes zabbix.pgsql.pkgs.

``zabbix.pgsql.schema``
^^^^^^^^^^^^^^^^^^^^^^^

Creates PostgreSQL schema for Zabbix.
Creates PostgreSQL schema for Zabbix. Includes zabbix.pgsql.pkgs.

``zabbix.proxy``
^^^^^^^^^^^^^^^^
Expand Down
32 changes: 2 additions & 30 deletions zabbix/pgsql/conf.sls
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,8 @@
{% set dbroot_user = settings.get('dbroot_user') -%}
{% set dbroot_pass = settings.get('dbroot_pass') -%}
# Install packages required for Salt postgres module
{% if settings.get('pkgs', defaults.get('pkgs', False))
and not settings.get('skip_pkgs', defaults.skip_pkgs) -%}
pgsql_packages:
pkg.installed:
- pkgs: {{ settings.get('pkgs', defaults.pkgs)|json }}
{% elif settings.get('skip_pkgs', defaults.skip_pkgs) -%}
pgsql_packages:
test.configurable_test_state:
- name: You skipped installation of packages required for Salt postgres module.
- changes: False
- result: True
{% else -%}
pgsql_packages:
test.configurable_test_state:
- name: Packages required for Salt postgres module are not defined
- changes: False
- result: False
- comment: |
Additional packages are required to manage the PostgreSQL database.
Please specify them in pillar as list.
Tip: you need postgresql-client packages, like:
zabbix-pgsql:
pkgs:
- postgresql-client-common
- postgresql-client
Or you can skip installing them, but formula likely fail without them.
zabbix-pgsql:
skip_pkgs: True
{% endif -%}
include:
- zabbix.pgsql.pkgs
zabbix_pgsql_user:
postgres_user.present:
Expand Down
34 changes: 34 additions & 0 deletions zabbix/pgsql/pkgs.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% from "zabbix/map.jinja" import zabbix with context -%}
{% set settings = salt['pillar.get']('zabbix-pgsql', {}) -%}
{% set defaults = zabbix.get('pgsql', {}) -%}
# Install packages required for Salt postgres module
{% if settings.get('pkgs', defaults.get('pkgs', False))
and not settings.get('skip_pkgs', defaults.skip_pkgs) -%}
pgsql_packages:
pkg.installed:
- pkgs: {{ settings.get('pkgs', defaults.pkgs)|json }}
{% elif settings.get('skip_pkgs', defaults.skip_pkgs) -%}
pgsql_packages:
test.configurable_test_state:
- name: You skipped installation of packages required for Salt postgres module.
- changes: False
- result: True
{% else -%}
pgsql_packages:
test.configurable_test_state:
- name: Packages required for Salt postgres module are not defined
- changes: False
- result: False
- comment: |
Additional packages are required to manage the PostgreSQL database.
Please specify them in pillar as list.
Tip: you need postgresql-client packages, like:
zabbix-pgsql:
pkgs:
- postgresql-client-common
- postgresql-client
Or you can skip installing them, but formula likely fail without them.
zabbix-pgsql:
skip_pkgs: True
{% endif -%}
2 changes: 1 addition & 1 deletion zabbix/pgsql/schema.sls
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% endif -%}
include:
- zabbix.pgsql.conf
- zabbix.pgsql.pkgs
check_db_pgsql:
test.configurable_test_state:
Expand Down

0 comments on commit 058a800

Please sign in to comment.