Merge pull request #360 from tpo/__postgres_extension
postgres extension
This commit is contained in:
commit
f1cd824a7d
4 changed files with 100 additions and 0 deletions
39
cdist/conf/type/__postgres_extension/gencode-remote
Executable file
39
cdist/conf/type/__postgres_extension/gencode-remote
Executable file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
# 2013 Tomas Pospisek (tpo_deb at sourcepole.ch)
|
||||||
|
#
|
||||||
|
# This type was created by Tomas Pospisek based on the
|
||||||
|
#__postgres_role type by Steven Armstrong
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
dbname=$( echo "$__object_id" | cut -d":" -f1 )
|
||||||
|
extension=$( echo "$__object_id" | cut -d":" -f2 )
|
||||||
|
|
||||||
|
state_should=$( cat "$__object/parameter/state" )
|
||||||
|
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
cmd="CREATE EXTENSION IF NOT EXISTS $extension"
|
||||||
|
echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
cmd="DROP EXTENSION IF EXISTS $extenstion"
|
||||||
|
echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
|
||||||
|
;;
|
||||||
|
esac
|
59
cdist/conf/type/__postgres_extension/man.rst
Normal file
59
cdist/conf/type/__postgres_extension/man.rst
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
cdist-type__postgres_extension(7)
|
||||||
|
=================================
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__postgres_extension - manage postgres extensions
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This cdist type allows you to create or drop postgres extensions.
|
||||||
|
|
||||||
|
The object you need to pass to __postgres_extension consists of
|
||||||
|
the database name and the extension name joined by a colon in the
|
||||||
|
following form:
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
dbname:extension
|
||||||
|
|
||||||
|
f.ex.
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
rails_test:unaccent
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
state
|
||||||
|
either "present" or "absent", defaults to "present"
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
__postgres_extension rails_test:unaccent
|
||||||
|
__postgres_extension --present rails_test:unaccent
|
||||||
|
__postgres_extension --absent rails_test:unaccent
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
:strong:`cdist-type__postgre_database`\ (7)
|
||||||
|
|
||||||
|
Postgres "Create Extension" documentation at: <http://www.postgresql.org/docs/current/static/sql-createextension.html>.
|
||||||
|
|
||||||
|
AUTHOR
|
||||||
|
-------
|
||||||
|
Tomas Pospisek <tpo_deb--@--sourcepole.ch>
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2014 Tomas Pospisek. You can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
|
@ -0,0 +1 @@
|
||||||
|
present
|
1
cdist/conf/type/__postgres_extension/parameter/optional
Normal file
1
cdist/conf/type/__postgres_extension/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
state
|
Loading…
Reference in a new issue