Initial import from repo
Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
This commit is contained in:
commit
29695f937e
8 changed files with 189 additions and 0 deletions
1
README
Symbolic link
1
README
Symbolic link
|
@ -0,0 +1 @@
|
|||
man.text
|
25
gencode-remote
Normal file
25
gencode-remote
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013-2015 ungleich GmbH (cdist at ungleich.ch)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/password") ]; then
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
password="$(cat "$__object/parameter/password")"
|
||||
echo "su - postgres -c \"psql -c \\\"ALTER ROLE $user WITH PASSWORD '$password'\\\"\""
|
||||
fi
|
64
man.text
Normal file
64
man.text
Normal file
|
@ -0,0 +1,64 @@
|
|||
cdist-type__ungleich_postgresql(7)
|
||||
=======================================
|
||||
ungleich GmbH <cdist--@--ungleich.ch>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__ungleich_postgresql - Setup PostgreSQL with backup
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Setup postgresql including some roles for application access
|
||||
|
||||
The development of this type was made possible by Panter AG (www.panter.ch).
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
user::
|
||||
Which system user to grant access to the database (creates a role)
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
password::
|
||||
Setup password for tcp based connections
|
||||
version::
|
||||
Define PostgreSQL version to use instead of default
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
no-backup::
|
||||
Do not backup database regulary
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__ungleich_postgresql --user app
|
||||
|
||||
# Setup password for tcp based connections (tcp not enabled by this type though)
|
||||
__ungleich_postgresql --user app --password 'hashedpw'
|
||||
|
||||
# Select different version (must be available in the repository)
|
||||
__ungleich_postgresql --user app --version 9.2
|
||||
|
||||
# Do not create backups
|
||||
__ungleich_postgresql --user app --no-backup
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2013-2015 ungleich GmbH (www.ungleich.ch).
|
||||
Free use of this software is granted under the terms
|
||||
of the GNU General Public License version 3 (GPLv3).
|
96
manifest
Normal file
96
manifest
Normal file
|
@ -0,0 +1,96 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013-2015 ungleich GmbH (cdist at ungleich.ch)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
|
||||
os=$(cat $__global/explorer/os)
|
||||
osversion=$(cat "$__global/explorer/os_version")
|
||||
|
||||
case "$os" in
|
||||
debian)
|
||||
postgres_lib=libpq-dev
|
||||
|
||||
case $osversion in
|
||||
6*)
|
||||
postgres_version=8.4
|
||||
;;
|
||||
7*)
|
||||
postgres_version=9.1
|
||||
;;
|
||||
8*)
|
||||
postgres_version=9.4
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OS Version: $osversion" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OS: $os" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Allow version override
|
||||
if [ -f "$__object/parameter/version" ]; then
|
||||
postgres_version=$(cat "$__object/parameter/version")
|
||||
fi
|
||||
|
||||
postgres_server="postgresql-${postgres_version}"
|
||||
|
||||
################################################################################
|
||||
# Configure PostgreSQL
|
||||
#
|
||||
|
||||
require="__package/$postgres_server" __postgres_role "$user" \
|
||||
--state present --login --createdb
|
||||
|
||||
__package "$postgres_server" --state present
|
||||
|
||||
require="__package/$postgres_server" __start_on_boot postgresql
|
||||
|
||||
################################################################################
|
||||
# Create backups
|
||||
#
|
||||
|
||||
if [ ! -f "$__object/parameter/no-backup" ]; then
|
||||
require="__package/$postgres_server" __directory /var/backups/postgres \
|
||||
--owner postgres --group postgres
|
||||
|
||||
require="__package/$postgres_server __directory/var/backups/postgres" __cron \
|
||||
pg_dumpall_under_day \
|
||||
--user postgres \
|
||||
--hour 8,9,10,11,12,14,15,16,17,18 --minute 0 \
|
||||
--command 'nice pg_dumpall | gzip > /var/backups/postgres/dumpall-$(date +\%H\%M).sql.gz'
|
||||
|
||||
require="__package/$postgres_server __directory/var/backups/postgres" __cron \
|
||||
pg_dumpall_archive \
|
||||
--user postgres \
|
||||
--hour 2 --minute 0 \
|
||||
--command 'nice pg_dumpall | gzip > /var/backups/postgres/dumpall-$(date +\%Y\%m\%d-\%H\%M).sql.gz'
|
||||
|
||||
# Delete local backups after 7 days
|
||||
require="__package/$postgres_server __directory/var/backups/postgres" __cron \
|
||||
pg_dump_cleanup \
|
||||
--user postgres \
|
||||
--hour 1 --minute 0 \
|
||||
--command 'find /var/backups/postgres -type f -mtime +7 -delete'
|
||||
fi
|
1
parameter/boolean
Normal file
1
parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
|||
no-backup
|
1
parameter/optional
Normal file
1
parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
version
|
1
parameter/required
Normal file
1
parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
user
|
0
singleton
Normal file
0
singleton
Normal file
Loading…
Reference in a new issue