forked from ungleich-public/cdist
add initial version of __rsync
Signed-off-by: Nico Schottelius <nico@freiheit.schottelius.org>
This commit is contained in:
parent
6e483497de
commit
3cc2f13b9b
7 changed files with 120 additions and 0 deletions
19
cdist/conf/type/__rsync/gencode-local
Normal file
19
cdist/conf/type/__rsync/gencode-local
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
source_dir=$(cat "$__object/parameter/source-dir")
|
||||||
|
remote_user=$(cat "$__object/parameter/remote-user")
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/destination-dir" ]; then
|
||||||
|
destination_dir=$(cat "$__object/parameter/destination-dir")
|
||||||
|
else
|
||||||
|
destination_dir="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set --
|
||||||
|
if [ -f "$__object/parameter/rsync-opts" ]; then
|
||||||
|
while read opts; do
|
||||||
|
set -- "$@" "$opts"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo rsync -a \
|
||||||
|
--no-owner --no-group \
|
||||||
|
-q "$@" "${source_dir}/" "${remote_user}@${__target_host}:$destination_dir"
|
17
cdist/conf/type/__rsync/gencode-remote
Normal file
17
cdist/conf/type/__rsync/gencode-remote
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
if [ -f "$__object/parameter/destination-dir" ]; then
|
||||||
|
destination_dir=$(cat "$__object/parameter/destination-dir")
|
||||||
|
else
|
||||||
|
destination_dir="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ownergroup=""
|
||||||
|
if [ -f "$__object/parameter/owner" ]; then
|
||||||
|
ownergroup=$(cat "$__object/parameter/owner")
|
||||||
|
fi
|
||||||
|
if [ -f "$__object/parameter/group" ]; then
|
||||||
|
ownergroup=":$(cat "$__object/parameter/group")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ownergroup" ]; then
|
||||||
|
echo chown -R "$ownergroup" "$destination_dir"
|
||||||
|
fi
|
77
cdist/conf/type/__rsync/man.text
Normal file
77
cdist/conf/type/__rsync/man.text
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
cdist-type__rsync(7)
|
||||||
|
====================
|
||||||
|
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__rsync - Mirror directories using rsync
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This cdist type allows you to mirror local directories to the
|
||||||
|
target host using rsync.
|
||||||
|
Rsync will be installed in the manifest of the type.
|
||||||
|
|
||||||
|
If group or owner are giveng, a recursive chown
|
||||||
|
will be executed on the target host.
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
source::
|
||||||
|
Where to take files from
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
group::
|
||||||
|
Group to chgrp to.
|
||||||
|
|
||||||
|
owner::
|
||||||
|
User to chown to.
|
||||||
|
|
||||||
|
destination::
|
||||||
|
Use this as the base destination instead of the object id
|
||||||
|
|
||||||
|
remote-user::
|
||||||
|
Use this user instead of the default "root" for rsync operations.
|
||||||
|
|
||||||
|
MESSAGES
|
||||||
|
--------
|
||||||
|
NONE
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# You can use any source directory
|
||||||
|
__rsync /tmp/testdir \
|
||||||
|
--source /etc
|
||||||
|
|
||||||
|
# Use source from type
|
||||||
|
__rsync /etc \
|
||||||
|
--source "$__type/files/package"
|
||||||
|
|
||||||
|
# Allow multiple __rsync objects to write to the same dir
|
||||||
|
__rsync mystuff \
|
||||||
|
--destination /usr/local/bin \
|
||||||
|
--source "$__type/files/package"
|
||||||
|
|
||||||
|
__rsync otherstuff \
|
||||||
|
--destination /usr/local/bin \
|
||||||
|
--source "$__type/files/package2"
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2015 Nico Schottelius. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
1
cdist/conf/type/__rsync/manifest
Normal file
1
cdist/conf/type/__rsync/manifest
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__package rsync
|
1
cdist/conf/type/__rsync/parameter/default/remote-user
Normal file
1
cdist/conf/type/__rsync/parameter/default/remote-user
Normal file
|
@ -0,0 +1 @@
|
||||||
|
root
|
4
cdist/conf/type/__rsync/parameter/optional
Normal file
4
cdist/conf/type/__rsync/parameter/optional
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
destination
|
||||||
|
owner
|
||||||
|
group
|
||||||
|
remote-user
|
1
cdist/conf/type/__rsync/parameter/required
Normal file
1
cdist/conf/type/__rsync/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
source-dir
|
Loading…
Reference in a new issue