forked from ungleich-public/cdist
Merge remote-tracking branch 'steven/master'
This commit is contained in:
commit
1abcee730b
13 changed files with 265 additions and 21 deletions
27
conf/type/__postgres_database/explorer/state
Executable file
27
conf/type/__postgres_database/explorer/state
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
name="$__object_id"
|
||||||
|
|
||||||
|
if su - postgres -c "echo '\q' | psql '$name'" 2>/dev/null; then
|
||||||
|
echo "present"
|
||||||
|
else
|
||||||
|
echo "absent"
|
||||||
|
fi
|
38
conf/type/__postgres_database/gencode-remote
Executable file
38
conf/type/__postgres_database/gencode-remote
Executable file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
name="$__object_id"
|
||||||
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
|
||||||
|
if [ "$state_should" != "$state_is" ]; then
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
owner=""
|
||||||
|
if [ -f "$__object/parameter/owner" ]; then
|
||||||
|
owner="-O '$(cat "$__object/parameter/owner")'"
|
||||||
|
fi
|
||||||
|
echo "su - postgres -c \"createdb $owner '$name'\""
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo "su - postgres -c \"dropdb '$name'\""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
44
conf/type/__postgres_database/man.text
Normal file
44
conf/type/__postgres_database/man.text
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
cdist-type__postgres_database(7)
|
||||||
|
================================
|
||||||
|
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__postgres_database - create/drop postgres databases
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This cdist type allows you to create or drop postgres databases.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
state::
|
||||||
|
either 'present' or 'absent'
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
owner::
|
||||||
|
the role owning this database
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
__postgres_database mydbname --state present --owner mydbusername
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
1
conf/type/__postgres_database/parameter/optional
Normal file
1
conf/type/__postgres_database/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
owner
|
1
conf/type/__postgres_database/parameter/required
Normal file
1
conf/type/__postgres_database/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
state
|
27
conf/type/__postgres_role/explorer/state
Executable file
27
conf/type/__postgres_role/explorer/state
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
name="$__object_id"
|
||||||
|
|
||||||
|
if su - postgres -c "psql -c '\du' | grep -q '^ *$name *|'"; then
|
||||||
|
echo "present"
|
||||||
|
else
|
||||||
|
echo "absent"
|
||||||
|
fi
|
54
conf/type/__postgres_role/gencode-remote
Executable file
54
conf/type/__postgres_role/gencode-remote
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
#
|
||||||
|
# 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
name="$__object_id"
|
||||||
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
if [ "$state_is" != "$state_should" ]; then
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
optional="password
|
||||||
|
login
|
||||||
|
createdb
|
||||||
|
createrole
|
||||||
|
superuser"
|
||||||
|
for parameter in $optional; do
|
||||||
|
if [ -f "$__object/parameter/$parameter" ]; then
|
||||||
|
value="$(cat "$__object/parameter/$parameter")"
|
||||||
|
eval $parameter=$value
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
[ -n "$password" ] && password="PASSWORD '$password'"
|
||||||
|
[ "$login" = "true" ] && login="LOGIN" || login="NOLOGIN"
|
||||||
|
[ "$createdb" = "true" ] && createdb="CREATEDB" || createdb="NOCREATEDB"
|
||||||
|
[ "$createrole" = "true" ] && createrole="CREATEROLE" || createrole="NOCREATEROLE"
|
||||||
|
[ "$superuser" = "true" ] && superuser="SUPERUSER" || superuser="NOSUPERUSER"
|
||||||
|
[ "$inherit" = "true" ] && inherit="INHERIT" || inherit="NOINHERIT"
|
||||||
|
|
||||||
|
cmd="CREATE ROLE $name WITH $password $login $createdb $createrole $superuser $inherit"
|
||||||
|
echo "su - postgres -c \"psql -c \\\"$cmd\\\"\""
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo "su - postgres -c \"dropuser \\\"$name\\\"\""
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
58
conf/type/__postgres_role/man.text
Normal file
58
conf/type/__postgres_role/man.text
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
cdist-type__postgres_role(7)
|
||||||
|
============================
|
||||||
|
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__postgres_role - manage postgres roles
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This cdist type allows you to create or drop postgres roles.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
state::
|
||||||
|
either 'present' or 'absent'
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
All optional parameter map directly to the corresponding postgres createrole
|
||||||
|
parameters.
|
||||||
|
|
||||||
|
password::
|
||||||
|
login::
|
||||||
|
createdb::
|
||||||
|
createrole::
|
||||||
|
superuser::
|
||||||
|
inherit::
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
__postgres_role myrole --state present
|
||||||
|
|
||||||
|
__postgres_role myrole --state present --password 'secret'
|
||||||
|
|
||||||
|
__postgres_role admin --state present --password 'very-secret' --superuser true
|
||||||
|
|
||||||
|
__postgres_role dbcustomer --state present --password 'bla' --createdb true
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
- http://www.postgresql.org/docs/current/static/sql-createrole.html
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
6
conf/type/__postgres_role/parameter/optional
Normal file
6
conf/type/__postgres_role/parameter/optional
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
password
|
||||||
|
login
|
||||||
|
createdb
|
||||||
|
createrole
|
||||||
|
superuser
|
||||||
|
inherit
|
1
conf/type/__postgres_role/parameter/required
Normal file
1
conf/type/__postgres_role/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
state
|
|
@ -41,6 +41,14 @@ CORE
|
||||||
and have it parsable by different (shinken) tool
|
and have it parsable by different (shinken) tool
|
||||||
-> given after manifest run already!
|
-> given after manifest run already!
|
||||||
|
|
||||||
|
- Allow types to have parameters without values (boolean flags).
|
||||||
|
e.g. __chair fancychair --pink --wood
|
||||||
|
would result in:
|
||||||
|
$__object/parameter/
|
||||||
|
pink # empty file
|
||||||
|
wood # empty file
|
||||||
|
|
||||||
|
|
||||||
TYPES
|
TYPES
|
||||||
------
|
------
|
||||||
- __ssh-keys (host/user)
|
- __ssh-keys (host/user)
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
- document object_id=$1 for manifest + gencode :-)
|
|
||||||
|
|
||||||
- update docs regarding flow in cdist-stages.text
|
|
||||||
- create man pages for new executables
|
|
||||||
- nuke legacy manpages
|
|
||||||
|
|
||||||
- prettify output of cdist-deploy-to, e.g.
|
|
||||||
|
|
||||||
Processing object __file/etc/cdist-configured
|
|
||||||
transfering type explorers ...
|
|
||||||
running type explorers ...
|
|
||||||
running manifest ...
|
|
||||||
running gencode ...
|
|
||||||
transfering object to target ...
|
|
||||||
running code ...
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
- align messages (already in todo for steven, but makes life much easier, thus repeated)
|
|
||||||
-> prefix all object stuff with $__self
|
|
||||||
-> __cdist_echo object string
|
|
||||||
-> $__cdist_object_self :-)
|
|
||||||
|
|
Loading…
Reference in a new issue