forked from ungleich-public/cdist
Merge branch 'master' into type__rbenv
This commit is contained in:
commit
490bad7b26
446 changed files with 8653 additions and 2094 deletions
|
|
@ -40,13 +40,20 @@ BANNER = """
|
|||
"8888P' `"888*"" R888" ` ^"F 'Y"
|
||||
"P' "" ""
|
||||
"""
|
||||
|
||||
DOT_CDIST = ".cdist"
|
||||
|
||||
REMOTE_COPY = "scp -o User=root -q"
|
||||
REMOTE_EXEC = "ssh -o User=root -q"
|
||||
|
||||
class Error(Exception):
|
||||
"""Base exception class for this project"""
|
||||
pass
|
||||
|
||||
class UnresolvableRequirementsError(cdist.Error):
|
||||
"""Resolving requirements failed"""
|
||||
pass
|
||||
|
||||
class CdistObjectError(Error):
|
||||
"""Something went wrong with an object"""
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
|
|
@ -20,6 +20,6 @@
|
|||
#
|
||||
#
|
||||
|
||||
if command -v hostname; then
|
||||
hostname
|
||||
if command -v uname >/dev/null; then
|
||||
uname -n
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@
|
|||
#
|
||||
#
|
||||
|
||||
if command -v uname; then
|
||||
if command -v uname 2>&1 >/dev/null; then
|
||||
uname -m
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -88,6 +88,11 @@ if [ -f /etc/SuSE-release ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f /etc/slackware-version ]; then
|
||||
echo slackware
|
||||
exit 0
|
||||
fi
|
||||
|
||||
uname_s="$(uname -s)"
|
||||
|
||||
# Assume there is no tr on the client -> do lower case ourselves
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ case "$($__explorer/os)" in
|
|||
redhat|centos)
|
||||
cat /etc/redhat-release
|
||||
;;
|
||||
slackware)
|
||||
cat /etc/slackware-version
|
||||
;;
|
||||
suse)
|
||||
cat /etc/SuSE-release
|
||||
;;
|
||||
|
|
|
|||
32
cdist/conf/type/__apt_key/explorer/state
Executable file
32
cdist/conf/type/__apt_key/explorer/state
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2014 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/>.
|
||||
#
|
||||
#
|
||||
# Get the current state of the apt key.
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/keyid" ]; then
|
||||
keyid="$(cat "$__object/parameter/keyid")"
|
||||
else
|
||||
keyid="$__object_id"
|
||||
fi
|
||||
|
||||
apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \
|
||||
&& echo present \
|
||||
|| echo absent
|
||||
42
cdist/conf/type/__apt_key/gencode-remote
Executable file
42
cdist/conf/type/__apt_key/gencode-remote
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2014 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/>.
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/keyid" ]; then
|
||||
keyid="$(cat "$__object/parameter/keyid")"
|
||||
else
|
||||
keyid="$__object_id"
|
||||
fi
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
|
||||
if [ "$state_should" = "$state_is" ]; then
|
||||
# nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
keyserver="$(cat "$__object/parameter/keyserver")"
|
||||
echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\""
|
||||
;;
|
||||
absent)
|
||||
echo "apt-key del \"$keyid\""
|
||||
;;
|
||||
esac
|
||||
61
cdist/conf/type/__apt_key/man.text
Normal file
61
cdist/conf/type/__apt_key/man.text
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
cdist-type__apt_key(7)
|
||||
======================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__apt_key - manage the list of keys used by apt
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Manages the list of keys used by apt to authenticate packages.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
'present' or 'absent'. Defaults to 'present'
|
||||
|
||||
keyid::
|
||||
the id of the key to add. Defaults to __object_id
|
||||
|
||||
keyserver::
|
||||
the keyserver from which to fetch the key. If omitted the default set in
|
||||
./parameter/default/keyserver is used.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Add Ubuntu Archive Automatic Signing Key
|
||||
__apt_key 437D05B5
|
||||
# Same thing
|
||||
__apt_key 437D05B5 --state present
|
||||
# Get rid of it
|
||||
__apt_key 437D05B5 --state absent
|
||||
|
||||
# same thing with human readable name and explicit keyid
|
||||
__apt_key UbuntuArchiveKey --keyid 437D05B5
|
||||
|
||||
# same thing with other keyserver
|
||||
__apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
1
cdist/conf/type/__apt_key/parameter/default/keyserver
Normal file
1
cdist/conf/type/__apt_key/parameter/default/keyserver
Normal file
|
|
@ -0,0 +1 @@
|
|||
subkeys.pgp.net
|
||||
1
cdist/conf/type/__apt_key/parameter/default/state
Normal file
1
cdist/conf/type/__apt_key/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
3
cdist/conf/type/__apt_key/parameter/optional
Normal file
3
cdist/conf/type/__apt_key/parameter/optional
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
state
|
||||
keyid
|
||||
keyserver
|
||||
32
cdist/conf/type/__apt_key_uri/explorer/state
Executable file
32
cdist/conf/type/__apt_key_uri/explorer/state
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2014 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/>.
|
||||
#
|
||||
#
|
||||
# Get the current state of the apt key.
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
apt-key list | grep -Fqe "$name" \
|
||||
&& echo present \
|
||||
|| echo absent
|
||||
45
cdist/conf/type/__apt_key_uri/gencode-remote
Executable file
45
cdist/conf/type/__apt_key_uri/gencode-remote
Executable file
|
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2014 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/>.
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
|
||||
if [ "$state_should" = "$state_is" ]; then
|
||||
# nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
uri="$(cat "$__object/parameter/uri")"
|
||||
printf 'curl -s -L "%s" | apt-key add -\n' "$uri"
|
||||
;;
|
||||
absent)
|
||||
cat << DONE
|
||||
keyid=\$(apt-key list | grep -B1 "$name" | awk '/pub/ { print \$2 }' | cut -d'/' -f 2)
|
||||
apt-key del \$keyid
|
||||
DONE
|
||||
;;
|
||||
esac
|
||||
51
cdist/conf/type/__apt_key_uri/man.text
Normal file
51
cdist/conf/type/__apt_key_uri/man.text
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
cdist-type__apt_key_uri(7)
|
||||
==========================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__apt_key_uri - add apt key from uri
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Download a key from an uri and add it to the apt keyring.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
uri::
|
||||
the uri from which to download the key
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
'present' or 'absent', defaults to 'present'
|
||||
|
||||
name::
|
||||
a name for this key, used when testing if it is already installed.
|
||||
Defaults to __object_id
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__apt_key_uri rabbitmq \
|
||||
--name 'RabbitMQ Release Signing Key <info@rabbitmq.com>' \
|
||||
--uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \
|
||||
--state present
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
21
cdist/conf/type/__apt_key_uri/manifest
Executable file
21
cdist/conf/type/__apt_key_uri/manifest
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013-2014 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/>.
|
||||
#
|
||||
|
||||
__package curl
|
||||
1
cdist/conf/type/__apt_key_uri/parameter/default/state
Normal file
1
cdist/conf/type/__apt_key_uri/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
2
cdist/conf/type/__apt_key_uri/parameter/optional
Normal file
2
cdist/conf/type/__apt_key_uri/parameter/optional
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
state
|
||||
name
|
||||
1
cdist/conf/type/__apt_key_uri/parameter/required
Normal file
1
cdist/conf/type/__apt_key_uri/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
uri
|
||||
42
cdist/conf/type/__apt_norecommends/man.text
Normal file
42
cdist/conf/type/__apt_norecommends/man.text
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
cdist-type__apt_norecommends(7)
|
||||
===============================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__apt_norecommends - configure apt to not install recommended packages
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Configure apt to not install any recommended or suggested packages.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__apt_norecommends
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2014 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
42
cdist/conf/type/__apt_norecommends/manifest
Executable file
42
cdist/conf/type/__apt_norecommends/manifest
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2014 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/>.
|
||||
#
|
||||
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
|
||||
case "$os" in
|
||||
ubuntu|debian)
|
||||
# No stinking recommends thank you very much.
|
||||
# If I want something installed I will do so myself.
|
||||
__file /etc/apt/apt.conf.d/99-no-recommends \
|
||||
--owner root --group root --mode 644 \
|
||||
--source - << DONE
|
||||
APT::Install-Recommends "0";
|
||||
APT::Install-Suggests "0";
|
||||
DONE
|
||||
;;
|
||||
*)
|
||||
cat >&2 << DONE
|
||||
The developer of this type (${__type##*/}) did not think your operating system
|
||||
($os) would have any use for it. If you think otherwise please submit a patch.
|
||||
DONE
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -22,7 +22,7 @@ name="$__object_id"
|
|||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
|
||||
if [ "$state_should" == "$state_is" ]; then
|
||||
if [ "$state_should" = "$state_is" ]; then
|
||||
# Nothing to do, move along
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ This cdist type allows manage ubuntu ppa repositories.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
The state the ppa should be in, either "present" or "absent".
|
||||
The state the ppa should be in, either 'present' or 'absent'.
|
||||
Defaults to 'present'
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
|
|
@ -29,6 +30,8 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Enable a ppa repository
|
||||
__apt_ppa ppa:sans-intern/missing-bits
|
||||
# same as
|
||||
__apt_ppa ppa:sans-intern/missing-bits --state present
|
||||
|
||||
# Disable a ppa repository
|
||||
|
|
@ -43,5 +46,5 @@ SEE ALSO
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -20,9 +20,10 @@
|
|||
|
||||
name="$__object_id"
|
||||
|
||||
__package python-software-properties --state present
|
||||
__package software-properties-common
|
||||
__package python-software-properties
|
||||
|
||||
require="__package/python-software-properties" \
|
||||
require="__package/software-properties-common __package/python-software-properties" \
|
||||
__file /usr/local/bin/remove-apt-repository \
|
||||
--source "$__type/files/remove-apt-repository" \
|
||||
--mode 0755
|
||||
|
|
|
|||
1
cdist/conf/type/__apt_ppa/parameter/default/state
Normal file
1
cdist/conf/type/__apt_ppa/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
15
cdist/conf/type/__apt_source/files/source.list.template
Executable file
15
cdist/conf/type/__apt_source/files/source.list.template
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
set -u
|
||||
|
||||
entry="$uri $distribution $component"
|
||||
cat << DONE
|
||||
# Created by cdist ${__type##*/}
|
||||
# Do not change. Changes will be overwritten.
|
||||
#
|
||||
|
||||
# $name
|
||||
deb ${forcedarch} $entry
|
||||
DONE
|
||||
if [ -f "$__object/parameter/include-src" ]; then
|
||||
echo "deb-src $entry"
|
||||
fi
|
||||
69
cdist/conf/type/__apt_source/man.text
Normal file
69
cdist/conf/type/__apt_source/man.text
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
cdist-type__apt_source(7)
|
||||
=========================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__apt_source - manage apt sources
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to manage apt sources.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
uri::
|
||||
the uri to the apt repository
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
arch::
|
||||
set this if you need to force and specific arch (ubuntu specific)
|
||||
|
||||
state::
|
||||
'present' or 'absent', defaults to 'present'
|
||||
|
||||
distribution::
|
||||
the distribution codename to use. Defaults to DISTRIB_CODENAME from
|
||||
the targets /etc/lsb-release
|
||||
|
||||
component::
|
||||
space delimited list of components to enable. Defaults to an empty string.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
include-src::
|
||||
include deb-src entries
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__apt_source rabbitmq \
|
||||
--uri http://www.rabbitmq.com/debian/ \
|
||||
--distribution testing \
|
||||
--component main \
|
||||
--include-src \
|
||||
--state present
|
||||
|
||||
__apt_source canonical_partner \
|
||||
--uri http://archive.canonical.com/ \
|
||||
--component partner --state present
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
56
cdist/conf/type/__apt_source/manifest
Executable file
56
cdist/conf/type/__apt_source/manifest
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2013 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="$(cat "$__object/parameter/state")"
|
||||
uri="$(cat "$__object/parameter/uri")"
|
||||
|
||||
if [ -f "$__object/parameter/distribution" ]; then
|
||||
distribution="$(cat "$__object/parameter/distribution")"
|
||||
else
|
||||
distribution="$(cat "$__global/explorer/lsb_codename")"
|
||||
fi
|
||||
if [ -f "$__object/parameter/component" ]; then
|
||||
component="$(cat "$__object/parameter/component")"
|
||||
else
|
||||
component=""
|
||||
fi
|
||||
if [ -f "$__object/parameter/arch" ]; then
|
||||
forcedarch="[arch=$(cat "$__object/parameter/arch")]"
|
||||
else
|
||||
forcedarch=""
|
||||
fi
|
||||
|
||||
# export variables for use in template
|
||||
export name
|
||||
export uri
|
||||
export distribution
|
||||
export component
|
||||
export forcedarch
|
||||
|
||||
# generate file from template
|
||||
mkdir "$__object/files"
|
||||
"$__type/files/source.list.template" > "$__object/files/source.list"
|
||||
__file "/etc/apt/sources.list.d/${name}.list" \
|
||||
--source "$__object/files/source.list" \
|
||||
--owner root --group root --mode 0644 \
|
||||
--state "$state"
|
||||
|
||||
require="$__object_name" __apt_update_index
|
||||
1
cdist/conf/type/__apt_source/parameter/boolean
Normal file
1
cdist/conf/type/__apt_source/parameter/boolean
Normal file
|
|
@ -0,0 +1 @@
|
|||
include-src
|
||||
1
cdist/conf/type/__apt_source/parameter/default/state
Normal file
1
cdist/conf/type/__apt_source/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
4
cdist/conf/type/__apt_source/parameter/optional
Normal file
4
cdist/conf/type/__apt_source/parameter/optional
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
state
|
||||
distribution
|
||||
component
|
||||
arch
|
||||
1
cdist/conf/type/__apt_source/parameter/required
Normal file
1
cdist/conf/type/__apt_source/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
uri
|
||||
21
cdist/conf/type/__block/explorer/block
Executable file
21
cdist/conf/type/__block/explorer/block
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
# 2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
|
||||
file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")"
|
||||
|
||||
# file does not exist, nothing we could do
|
||||
[ -f "$file" ] || exit 0
|
||||
|
||||
prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id")
|
||||
suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id")
|
||||
awk -v prefix="$prefix" -v suffix="$suffix" '{
|
||||
if (index($0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index($0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
print
|
||||
}
|
||||
}' "$file"
|
||||
84
cdist/conf/type/__block/gencode-remote
Executable file
84
cdist/conf/type/__block/gencode-remote
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 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/>.
|
||||
#
|
||||
|
||||
file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")"
|
||||
state_should=$(cat "$__object/parameter/state")
|
||||
prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id")
|
||||
suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id")
|
||||
|
||||
block="$__object/files/block"
|
||||
if [ ! -s "$__object/explorer/block" ]; then
|
||||
state_is='absent'
|
||||
else
|
||||
state_is=$(diff -q "$block" "$__object/explorer/block" >/dev/null \
|
||||
&& echo present \
|
||||
|| echo changed
|
||||
)
|
||||
fi
|
||||
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
if [ "$state_should" = "$state_is" ]; then
|
||||
# Nothing to do, move along
|
||||
exit 0
|
||||
fi
|
||||
|
||||
remove_block() {
|
||||
cat << DONE
|
||||
tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
|
||||
# preserve ownership and permissions of existing file
|
||||
if [ -f "$file" ]; then
|
||||
cp -p "$file" "\$tmpfile"
|
||||
fi
|
||||
awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index(\$0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index(\$0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
} else {
|
||||
print
|
||||
}
|
||||
}' "$file" > "\$tmpfile"
|
||||
mv -f "\$tmpfile" "$file"
|
||||
DONE
|
||||
}
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
if [ "$state_is" = "changed" ]; then
|
||||
echo update >> "$__messages_out"
|
||||
remove_block
|
||||
else
|
||||
echo add >> "$__messages_out"
|
||||
fi
|
||||
cat << DONE
|
||||
cat >> "$file" << ${__type##*/}_DONE
|
||||
$(cat "$block")
|
||||
${__type##*/}_DONE
|
||||
DONE
|
||||
;;
|
||||
absent)
|
||||
echo remove >> "$__messages_out"
|
||||
remove_block
|
||||
;;
|
||||
esac
|
||||
82
cdist/conf/type/__block/man.text
Normal file
82
cdist/conf/type/__block/man.text
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
cdist-type__block(7)
|
||||
====================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__block - Manage blocks of text in files
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Manage a block of text in an existing file.
|
||||
The block is identified using the prefix and suffix parameters.
|
||||
Everything between prefix and suffix is considered to be a managed block
|
||||
of text.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
text::
|
||||
the text to manage.
|
||||
If text is '-' (dash), take what was written to stdin as the text.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
file::
|
||||
the file in which to manage the text block.
|
||||
Defaults to object_id.
|
||||
|
||||
prefix::
|
||||
the prefix to add before the text.
|
||||
Defaults to #cdist:__block/$__object_id
|
||||
|
||||
suffix::
|
||||
the prefix to add after the text.
|
||||
Defaults to #/cdist:__block/$__object_id
|
||||
|
||||
state::
|
||||
'present' or 'absent', defaults to 'present'
|
||||
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
add::
|
||||
block was added
|
||||
update::
|
||||
block was updated/changed
|
||||
remove::
|
||||
block was removed
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# text from argument
|
||||
__block /path/to/file \
|
||||
--prefix '#start' \
|
||||
--suffix '#end' \
|
||||
--text 'some\nblock of\ntext'
|
||||
|
||||
# text from stdin
|
||||
__block some-id \
|
||||
--file /path/to/file \
|
||||
--text - << DONE
|
||||
here some block
|
||||
of text
|
||||
DONE
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2013 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
36
cdist/conf/type/__block/manifest
Executable file
36
cdist/conf/type/__block/manifest
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013-2014 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/>.
|
||||
#
|
||||
|
||||
|
||||
file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")"
|
||||
prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id")
|
||||
suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id")
|
||||
text=$(cat "$__object/parameter/text")
|
||||
|
||||
mkdir "$__object/files"
|
||||
# Generate text block for inclusion in file
|
||||
block="$__object/files/block"
|
||||
echo "$prefix" > "$block"
|
||||
if [ "$text" = "-" ]; then
|
||||
cat "$__object/stdin" >> "$block"
|
||||
else
|
||||
cat "$text" >> "$block"
|
||||
fi
|
||||
echo "$suffix" >> "$block"
|
||||
1
cdist/conf/type/__block/parameter/default/state
Normal file
1
cdist/conf/type/__block/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
4
cdist/conf/type/__block/parameter/optional
Normal file
4
cdist/conf/type/__block/parameter/optional
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
file
|
||||
prefix
|
||||
state
|
||||
suffix
|
||||
1
cdist/conf/type/__block/parameter/required
Normal file
1
cdist/conf/type/__block/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
text
|
||||
34
cdist/conf/type/__ccollect_source/explorer/cksum
Executable file
34
cdist/conf/type/__ccollect_source/explorer/cksum
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# Retrieve the md5sum of a file to be created, if it is already existing.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
if [ -e "$destination" ]; then
|
||||
if [ -f "$destination" ]; then
|
||||
cksum < "$destination"
|
||||
else
|
||||
echo "NO REGULAR FILE"
|
||||
fi
|
||||
else
|
||||
echo "NO FILE FOUND, NO CHECKSUM CALCULATED."
|
||||
fi
|
||||
47
cdist/conf/type/__ccollect_source/explorer/stat
Executable file
47
cdist/conf/type/__ccollect_source/explorer/stat
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
# nothing to work with, nothing we could do
|
||||
[ -e "$destination" ] || exit 0
|
||||
|
||||
os=$("$__explorer/os")
|
||||
case "$os" in
|
||||
"freebsd")
|
||||
# FIXME: should be something like this based on man page, but can not test
|
||||
stat -f "type: %ST
|
||||
owner: %Du %Su
|
||||
group: %Dg %Sg
|
||||
mode: %Op %Sp
|
||||
size: %Dz
|
||||
links: %Dl
|
||||
" "$destination"
|
||||
;;
|
||||
*)
|
||||
stat --printf="type: %F
|
||||
owner: %u %U
|
||||
group: %g %G
|
||||
mode: %a %A
|
||||
size: %s
|
||||
links: %h
|
||||
" "$destination"
|
||||
;;
|
||||
esac
|
||||
33
cdist/conf/type/__ccollect_source/explorer/type
Executable file
33
cdist/conf/type/__ccollect_source/explorer/type
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
if [ ! -e "$destination" ]; then
|
||||
echo none
|
||||
elif [ -h "$destination" ]; then
|
||||
echo symlink
|
||||
elif [ -f "$destination" ]; then
|
||||
echo file
|
||||
elif [ -d "$destination" ]; then
|
||||
echo directory
|
||||
else
|
||||
echo unknown
|
||||
fi
|
||||
93
cdist/conf/type/__ccollect_source/gencode-remote
Executable file
93
cdist/conf/type/__ccollect_source/gencode-remote
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
type="$(cat "$__object/explorer/type")"
|
||||
stat_file="$__object/explorer/stat"
|
||||
|
||||
|
||||
get_current_value() {
|
||||
if [ -s "$stat_file" ]; then
|
||||
_name="$1"
|
||||
_value="$2"
|
||||
case "$_value" in
|
||||
[0-9]*)
|
||||
_index=2
|
||||
;;
|
||||
*)
|
||||
_index=3
|
||||
;;
|
||||
esac
|
||||
awk '/'"$_name"':/ { print $'$_index' }' "$stat_file"
|
||||
unset _name _value _index
|
||||
fi
|
||||
}
|
||||
|
||||
set_group() {
|
||||
echo chgrp \"$1\" \"$destination\"
|
||||
echo chgrp $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_owner() {
|
||||
echo chown \"$1\" \"$destination\"
|
||||
echo chown $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_mode() {
|
||||
echo chmod \"$1\" \"$destination\"
|
||||
echo chmod $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_attributes=
|
||||
case "$state_should" in
|
||||
present|exists)
|
||||
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by
|
||||
# clearing S_ISUID and S_ISGID bits (see chown(2))
|
||||
for attribute in group owner mode; do
|
||||
if [ -f "$__object/parameter/$attribute" ]; then
|
||||
value_should="$(cat "$__object/parameter/$attribute")"
|
||||
|
||||
# change 0xxx format to xxx format => same as stat returns
|
||||
if [ "$attribute" = mode ]; then
|
||||
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')"
|
||||
fi
|
||||
|
||||
value_is="$(get_current_value "$attribute" "$value_should")"
|
||||
if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then
|
||||
"set_$attribute" "$value_should"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
;;
|
||||
|
||||
absent)
|
||||
if [ "$type" = "file" ]; then
|
||||
echo rm -f \"$destination\"
|
||||
echo remove >> "$__messages_out"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
64
cdist/conf/type/__ccollect_source/man.text
Normal file
64
cdist/conf/type/__ccollect_source/man.text
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
cdist-type__ccollect_source(7)
|
||||
==============================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__ccollect_source - Manage ccollect sources
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to create or delete ccollect sources.
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
source::
|
||||
The source from which to backup
|
||||
destination::
|
||||
The destination directory
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
'present' or 'absent', defaults to 'present'
|
||||
ccollectconf::
|
||||
The CCOLLECT_CONF directory. Defaults to /etc/ccollect.
|
||||
|
||||
|
||||
OPTIONAL MULTIPLE PARAMETERS
|
||||
----------------------------
|
||||
exclude::
|
||||
Paths to exclude of backup
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
verbose::
|
||||
Whether to report backup verbosely
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__ccollect_source doc.ungleich.ch \
|
||||
--source doc.ungleich.ch:/ \
|
||||
--destination /backup/doc.ungleich.ch \
|
||||
--exclude '/proc/*' --exclude '/sys/*' \
|
||||
--verbose
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- ccollect(1)
|
||||
- http://www.nico.schottelius.org/software/ccollect/
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2014 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
53
cdist/conf/type/__ccollect_source/manifest
Executable file
53
cdist/conf/type/__ccollect_source/manifest
Executable file
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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="$(cat "$__object/parameter/state")"
|
||||
source="$(cat "$__object/parameter/source")"
|
||||
destination="$(cat "$__object/parameter/destination")"
|
||||
ccollectconf="$(cat "$__object/parameter/ccollectconf" | sed 's,/$,,')"
|
||||
|
||||
sourcedir="$ccollectconf/sources"
|
||||
basedir="$sourcedir/$name"
|
||||
|
||||
destination_file="$basedir/destination"
|
||||
source_file="$basedir/source"
|
||||
exclude_file="$basedir/exclude"
|
||||
verbose_file="$basedir/verbose"
|
||||
|
||||
__directory "$basedir" --state "$state"
|
||||
|
||||
export require="__directory$basedir"
|
||||
echo "$destination" | __file "$destination_file" --source - --state "$state"
|
||||
echo "$source" | __file "$source_file" --source - --state "$state"
|
||||
|
||||
################################################################################
|
||||
# Booleans
|
||||
if [ -f "$__object/parameter/verbose" ]; then
|
||||
verbosestate="present"
|
||||
else
|
||||
verbosestate="absent"
|
||||
fi
|
||||
__file "$verbose_file" --state "$verbosestate"
|
||||
|
||||
if [ -f "$__object/parameter/exclude" ]; then
|
||||
__file "$exclude_file" --source - --state "$state" \
|
||||
< "$__object/parameter/exclude"
|
||||
fi
|
||||
1
cdist/conf/type/__ccollect_source/parameter/boolean
Normal file
1
cdist/conf/type/__ccollect_source/parameter/boolean
Normal file
|
|
@ -0,0 +1 @@
|
|||
verbose
|
||||
|
|
@ -0,0 +1 @@
|
|||
/etc/ccollect
|
||||
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
2
cdist/conf/type/__ccollect_source/parameter/optional
Normal file
2
cdist/conf/type/__ccollect_source/parameter/optional
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
ccollectconf
|
||||
state
|
||||
|
|
@ -0,0 +1 @@
|
|||
exclude
|
||||
2
cdist/conf/type/__ccollect_source/parameter/required
Normal file
2
cdist/conf/type/__ccollect_source/parameter/required
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
source
|
||||
destination
|
||||
63
cdist/conf/type/__cdist/man.text
Normal file
63
cdist/conf/type/__cdist/man.text
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
cdist-type__cdist(7)
|
||||
====================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__cdist - Manage cdist installations
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to easily setup cdist
|
||||
on another box, to allow the other box to configure
|
||||
systems.
|
||||
|
||||
This type is *NOT* required by target hosts.
|
||||
It is only helpful to build FROM which you configure
|
||||
other hosts.
|
||||
|
||||
This type will use git to clone
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
username::
|
||||
Select the user to create for the cdist installation.
|
||||
Defaults to "cdist".
|
||||
|
||||
source::
|
||||
Select the source from which to clone cdist from.
|
||||
Defaults to "git://github.com/telmich/cdist.git".
|
||||
|
||||
|
||||
branch::
|
||||
Select the branch to checkout from.
|
||||
Defaults to "master".
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Install cdist for user cdist in her home as subfolder cdist
|
||||
__cdist /home/cdist/cdist
|
||||
|
||||
# Use alternative source
|
||||
__cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2013 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
47
cdist/conf/type/__cdist/manifest
Executable file
47
cdist/conf/type/__cdist/manifest
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
|
||||
directory="$__object_id"
|
||||
|
||||
if [ -f "$__object/parameter/shell" ]; then
|
||||
shell="--shell $(cat "$__object/parameter/shell")"
|
||||
else
|
||||
shell=""
|
||||
fi
|
||||
|
||||
username="$(cat "$__object/parameter/username")"
|
||||
|
||||
branch="$(cat "$__object/parameter/branch")"
|
||||
|
||||
source="$(cat "$__object/parameter/source")"
|
||||
|
||||
# Currently hardcoded - if anyone cares, make a parameter
|
||||
# out of it
|
||||
home=/home/$username
|
||||
|
||||
__user "$username" --home "$home" $shell
|
||||
|
||||
require="__user/$username" __directory "$home" \
|
||||
--owner "$username"
|
||||
|
||||
require="__user/$username __directory/$home" __git "$directory" \
|
||||
--source "$source" \
|
||||
--owner "$username" --branch "$branch"
|
||||
1
cdist/conf/type/__cdist/parameter/default/branch
Normal file
1
cdist/conf/type/__cdist/parameter/default/branch
Normal file
|
|
@ -0,0 +1 @@
|
|||
master
|
||||
1
cdist/conf/type/__cdist/parameter/default/source
Normal file
1
cdist/conf/type/__cdist/parameter/default/source
Normal file
|
|
@ -0,0 +1 @@
|
|||
git://github.com/telmich/cdist.git
|
||||
1
cdist/conf/type/__cdist/parameter/default/username
Normal file
1
cdist/conf/type/__cdist/parameter/default/username
Normal file
|
|
@ -0,0 +1 @@
|
|||
cdist
|
||||
4
cdist/conf/type/__cdist/parameter/optional
Normal file
4
cdist/conf/type/__cdist/parameter/optional
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
branch
|
||||
source
|
||||
username
|
||||
shell
|
||||
22
cdist/conf/type/__cron/explorer/entry
Executable file → Normal file
22
cdist/conf/type/__cron/explorer/entry
Executable file → Normal file
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -18,22 +19,7 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
name="$__object_id"
|
||||
name="$__object_name"
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
|
||||
prefix="#cdist:__cron/$name"
|
||||
suffix="#/cdist:__cron/$name"
|
||||
|
||||
crontab -u $user -l 2>/dev/null | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index($0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index($0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
print
|
||||
}
|
||||
}
|
||||
'
|
||||
crontab -u $user -l 2>/dev/null | grep "# $name\$" || true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2013 Thomas Oettli (otho at sfs.biz)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -18,40 +20,47 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
os="$(cat "$__global/explorer/os")"
|
||||
name="$__object_name"
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is=$(diff -q "$__object/parameter/entry" "$__object/explorer/entry" \
|
||||
&& echo present \
|
||||
|| echo absent
|
||||
)
|
||||
command="$(cat "$__object/parameter/command")"
|
||||
|
||||
# FreeBSD mktemp doesn't allow execution without at least one param
|
||||
if [ "$os" = "freebsd" ]; then
|
||||
mktemp="mktemp -t tmp"
|
||||
if [ -f "$__object/parameter/raw" ]; then
|
||||
raw="$(cat "$__object/parameter/raw")"
|
||||
entry="$raw $command"
|
||||
elif [ -f "$__object/parameter/raw_command" ]; then
|
||||
entry="$command"
|
||||
else
|
||||
mktemp="mktemp"
|
||||
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
||||
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
||||
day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")"
|
||||
month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")"
|
||||
day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")"
|
||||
entry="$minute $hour $day_of_month $month $day_of_week $command"
|
||||
fi
|
||||
|
||||
if [ "$state_is" != "$state_should" ]; then
|
||||
case "$state_should" in
|
||||
present)
|
||||
cat << DONE
|
||||
tmp=\$($mktemp)
|
||||
crontab -u $user -l > \$tmp
|
||||
cat >> \$tmp << EOC
|
||||
$(cat "$__object/parameter/entry")
|
||||
EOC
|
||||
crontab -u $user \$tmp
|
||||
rm \$tmp
|
||||
DONE
|
||||
;;
|
||||
absent)
|
||||
# defined in type manifest
|
||||
prefix="$(cat "$__object/parameter/prefix")"
|
||||
suffix="$(cat "$__object/parameter/suffix")"
|
||||
cat << DONE
|
||||
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
entry="$entry # $name"
|
||||
mkdir "$__object/files"
|
||||
echo "$entry" > "$__object/files/entry"
|
||||
|
||||
if diff -q "$__object/files/entry" "$__object/explorer/entry" >/dev/null; then
|
||||
state_is=present
|
||||
else
|
||||
state_is=absent
|
||||
fi
|
||||
|
||||
state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
|
||||
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
# If anything is going to change, ensure the old entries are
|
||||
# not present anymore
|
||||
|
||||
# These are the old markers
|
||||
prefix="#cdist:__cron/$__object_id"
|
||||
suffix="#/cdist:__cron/$__object_id"
|
||||
filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V"
|
||||
cat << DONE
|
||||
crontab -u $user -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index(\$0,prefix)) {
|
||||
triggered=1
|
||||
|
|
@ -66,6 +75,17 @@ crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
|
|||
}
|
||||
' | crontab -u $user -
|
||||
DONE
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
# if we insert new entry, filter also all entrys out with the same id
|
||||
echo "("
|
||||
echo "crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" | grep -v \"# $name\\$\" 2>/dev/null || true"
|
||||
echo "echo '$entry'"
|
||||
echo ") | crontab -u $user -"
|
||||
;;
|
||||
absent)
|
||||
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\"
|
||||
echo "grep -v \"# $name\\$\" | crontab -u $user -"
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ raw::
|
|||
Can for example be used to specify cron EXTENSIONS like reboot, yearly etc.
|
||||
See crontab(5) for the extensions if any that your cron implementation
|
||||
implements.
|
||||
raw_command::
|
||||
Take whatever the user has given in the commmand and ignore everything else.
|
||||
If given, the command will be added to crontab.
|
||||
Can for example be used to define variables like SHELL or MAILTO.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
|
@ -57,6 +61,10 @@ __cron some-id --user root --command "/path/to/script" \
|
|||
|
||||
# remove cronjob
|
||||
__cron some-id --user root --command "/path/to/script" --state absent
|
||||
|
||||
# define default shell
|
||||
__cron some-id --user root --raw_command --command "SHELL=/bin/bash" \
|
||||
--state present
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
@ -68,5 +76,5 @@ SEE ALSO
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
Copyright \(C) 2011-2013 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
|
|
|
|||
29
cdist/conf/type/__cron/manifest
Executable file → Normal file
29
cdist/conf/type/__cron/manifest
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2013 Thomas Oettli (otho at sfs.biz)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -18,28 +18,7 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
name="$__object_id"
|
||||
user="$(cat "$__object/parameter/user")"
|
||||
command="$(cat "$__object/parameter/command")"
|
||||
|
||||
# set defaults
|
||||
test -f "$__object/parameter/state" || echo "present" > "$__object/parameter/state"
|
||||
|
||||
if [ -f "$__object/parameter/raw" ]; then
|
||||
raw="$(cat "$__object/parameter/raw")"
|
||||
entry="$raw $command"
|
||||
else
|
||||
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
||||
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
||||
day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")"
|
||||
month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")"
|
||||
day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")"
|
||||
entry="$minute $hour $day_of_month $month $day_of_week $command"
|
||||
if [ -f "$__object/parameter/raw" ] && [ -f "$__object/parameter/raw_command" ]; then
|
||||
echo "ERROR: both raw and raw_command specified" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# NOTE: if changed, also change in explorers
|
||||
prefix="#cdist:__cron/$name"
|
||||
suffix="#/cdist:__cron/$name"
|
||||
echo "$prefix" | tee "$__object/parameter/prefix" > "$__object/parameter/entry"
|
||||
echo "$entry" >> "$__object/parameter/entry"
|
||||
echo "$suffix" | tee "$__object/parameter/suffix" >> "$__object/parameter/entry"
|
||||
|
|
|
|||
1
cdist/conf/type/__cron/parameter/boolean
Normal file
1
cdist/conf/type/__cron/parameter/boolean
Normal file
|
|
@ -0,0 +1 @@
|
|||
raw_command
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -21,6 +21,12 @@
|
|||
# Setup selections
|
||||
#
|
||||
|
||||
filename="$(cat "$__object/parameter/file")"
|
||||
|
||||
if [ "$filename" = "-" ]; then
|
||||
filename="$__object/stdin"
|
||||
fi
|
||||
|
||||
echo "debconf-set-selections << __file-eof"
|
||||
cat "$(cat "$__object/parameter/file")"
|
||||
cat "$filename"
|
||||
echo "__file-eof"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ to setup configuration parameters.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
file::
|
||||
If supplied, use the given filename as input for debconf-set-selections(1)
|
||||
Use the given filename as input for debconf-set-selections(1)
|
||||
If filename is "-", read from stdin.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
|
@ -29,15 +30,21 @@ __debconf_set_selections nslcd --file /path/to/file
|
|||
|
||||
# Setup configuration for nslcd from another type
|
||||
__debconf_set_selections nslcd --file "$__type/files/preseed/nslcd"
|
||||
|
||||
__debconf_set_selections nslcd --file - << eof
|
||||
gitolite gitolite/gituser string git
|
||||
eof
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__update_alternatives(7)
|
||||
- debconf-set-selections(1)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Nico Schottelius. Free use of this software is
|
||||
Copyright \(C) 2011-2014 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
|
|
|
|||
43
cdist/conf/type/__directory/explorer/stat
Executable file
43
cdist/conf/type/__directory/explorer/stat
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
# nothing to work with, nothing we could do
|
||||
[ -e "$destination" ] || exit 0
|
||||
|
||||
os=$("$__explorer/os")
|
||||
case "$os" in
|
||||
"freebsd")
|
||||
# FIXME: should be something like this based on man page, but can not test
|
||||
stat -f "type: %ST
|
||||
owner: %Du %Su
|
||||
group: %Dg %Sg
|
||||
mode: %Op %Sp
|
||||
" "$destination"
|
||||
;;
|
||||
*)
|
||||
stat --printf="type: %F
|
||||
owner: %u %U
|
||||
group: %g %G
|
||||
mode: %a %A
|
||||
" "$destination"
|
||||
;;
|
||||
esac
|
||||
33
cdist/conf/type/__directory/explorer/type
Executable file
33
cdist/conf/type/__directory/explorer/type
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
if [ ! -e "$destination" ]; then
|
||||
echo none
|
||||
elif [ -h "$destination" ]; then
|
||||
echo symlink
|
||||
elif [ -f "$destination" ]; then
|
||||
echo file
|
||||
elif [ -d "$destination" ]; then
|
||||
echo directory
|
||||
else
|
||||
echo unknown
|
||||
fi
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2013 Steven Armstrong (steven-cdist armstrong.cc)
|
||||
# 2014 Daniel Heule (hda at sfs.biz)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -18,42 +20,97 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
state_should="present"
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
[ "$state_should" = "$state_is" ] && exit 0
|
||||
|
||||
destination="/$__object_id"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
type="$(cat "$__object/explorer/type")"
|
||||
stat_file="$__object/explorer/stat"
|
||||
|
||||
# variable to keep track if we have to set directory attributes
|
||||
set_attributes=
|
||||
|
||||
mkdiropt=""
|
||||
[ -f "$__object/parameter/parents" ] && mkdiropt="-p"
|
||||
|
||||
recursive=""
|
||||
[ -f "$__object/parameter/recursive" ] && recursive="-R"
|
||||
if [ -f "$__object/parameter/recursive" ]; then
|
||||
recursive="-R"
|
||||
# need to allways set attributes when recursive is given
|
||||
# as we don't want to check all subfolders/files
|
||||
set_attributes=1
|
||||
fi
|
||||
|
||||
get_current_value() {
|
||||
if [ -s "$stat_file" ]; then
|
||||
_name="$1"
|
||||
_value="$2"
|
||||
case "$_value" in
|
||||
[0-9]*)
|
||||
_index=2
|
||||
;;
|
||||
*)
|
||||
_index=3
|
||||
;;
|
||||
esac
|
||||
awk '/'"$_name"':/ { print $'$_index' }' "$stat_file"
|
||||
unset _name _value _index
|
||||
fi
|
||||
}
|
||||
|
||||
set_group() {
|
||||
echo chgrp $recursive \"$1\" \"$destination\"
|
||||
echo chgrp $recursive $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_owner() {
|
||||
echo chown $recursive \"$1\" \"$destination\"
|
||||
echo chown $recursive $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_mode() {
|
||||
echo chmod $recursive \"$1\" \"$destination\"
|
||||
echo chmod $recursive $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo mkdir $mkdiropt \"$destination\"
|
||||
present)
|
||||
if [ "$type" != "directory" ]; then
|
||||
set_attributes=1
|
||||
if [ "$type" != "none" ]; then
|
||||
# our destination is not a directory, remove whatever is there
|
||||
# and then create our directory and set all attributes
|
||||
echo rm -f "\"$destination\""
|
||||
echo "remove non directory" >> "$__messages_out"
|
||||
fi
|
||||
echo "mkdir $mkdiropt \"$destination\""
|
||||
echo "create" >> "$__messages_out"
|
||||
fi
|
||||
|
||||
# Mode settings
|
||||
if [ -f "$__object/parameter/mode" ]; then
|
||||
echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\"
|
||||
fi
|
||||
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by
|
||||
# clearing S_ISUID and S_ISGID bits (see chown(2))
|
||||
for attribute in group owner mode; do
|
||||
if [ -f "$__object/parameter/$attribute" ]; then
|
||||
value_should="$(cat "$__object/parameter/$attribute")"
|
||||
value_is="$(get_current_value "$attribute" "$value_should")"
|
||||
|
||||
# Group
|
||||
if [ -f "$__object/parameter/group" ]; then
|
||||
echo chgrp $recursive \"$(cat "$__object/parameter/group")\" \"$destination\"
|
||||
fi
|
||||
# change 0xxx format to xxx format => same as stat returns
|
||||
if [ "$attribute" = mode ]; then
|
||||
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')"
|
||||
fi
|
||||
|
||||
# Owner
|
||||
if [ -f "$__object/parameter/owner" ]; then
|
||||
echo chown $recursive \"$(cat "$__object/parameter/owner")\" \"$destination\"
|
||||
if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then
|
||||
"set_$attribute" "$value_should"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
;;
|
||||
absent)
|
||||
if [ "$type" = "directory" ]; then
|
||||
echo rm -rf \"$destination\"
|
||||
echo remove >> "$__messages_out"
|
||||
fi
|
||||
;;
|
||||
absent)
|
||||
echo rm -rf \"$destination\"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -36,12 +36,31 @@ owner::
|
|||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
parents::
|
||||
Whether to create parents as well (mkdir -p behaviour)
|
||||
Whether to create parents as well (mkdir -p behaviour).
|
||||
Warning: all intermediate directory permissions default
|
||||
to whatever mkdir -p does.
|
||||
|
||||
Usually this means root:root, 0700.
|
||||
|
||||
recursive::
|
||||
If supplied the chgrp and chown call will run recursively.
|
||||
This does *not* influence the behaviour of chmod.
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
chgrp <group>::
|
||||
Changed group membership
|
||||
chown <owner>::
|
||||
Changed owner
|
||||
chmod <mode>::
|
||||
Changed mode
|
||||
create::
|
||||
Empty directory was created
|
||||
remove::
|
||||
Directory exists, but state is absent, directory will be removed by generated code.
|
||||
remove non directory::
|
||||
Someting other than a directory with the same name exists and was removed prior to create.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
|
|
|||
1
cdist/conf/type/__directory/parameter/default/state
Normal file
1
cdist/conf/type/__directory/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
47
cdist/conf/type/__file/explorer/stat
Executable file
47
cdist/conf/type/__file/explorer/stat
Executable file
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
# nothing to work with, nothing we could do
|
||||
[ -e "$destination" ] || exit 0
|
||||
|
||||
os=$("$__explorer/os")
|
||||
case "$os" in
|
||||
"freebsd")
|
||||
# FIXME: should be something like this based on man page, but can not test
|
||||
stat -f "type: %ST
|
||||
owner: %Du %Su
|
||||
group: %Dg %Sg
|
||||
mode: %Op %Sp
|
||||
size: %Dz
|
||||
links: %Dl
|
||||
" "$destination"
|
||||
;;
|
||||
*)
|
||||
stat --printf="type: %F
|
||||
owner: %u %U
|
||||
group: %g %G
|
||||
mode: %a %A
|
||||
size: %s
|
||||
links: %h
|
||||
" "$destination"
|
||||
;;
|
||||
esac
|
||||
33
cdist/conf/type/__file/explorer/type
Executable file
33
cdist/conf/type/__file/explorer/type
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2013 Steven Armstrong (steven-cdist 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/>.
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
if [ ! -e "$destination" ]; then
|
||||
echo none
|
||||
elif [ -h "$destination" ]; then
|
||||
echo symlink
|
||||
elif [ -f "$destination" ]; then
|
||||
echo file
|
||||
elif [ -d "$destination" ]; then
|
||||
echo directory
|
||||
else
|
||||
echo unknown
|
||||
fi
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2013 Steven Armstrong (steven-cdist armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -17,34 +18,61 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# __file is a very basic type, which will probably be reused quite often
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
state_should=present
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
exists="$(cat "$__object/explorer/exists")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
type="$(cat "$__object/explorer/type")"
|
||||
|
||||
[ "$state_should" = "exists" -a "$exists" = "yes" ] && exit 0 # nothing to do
|
||||
[ "$state_should" = "exists" -a "$type" = "file" ] && exit 0 # nothing to do
|
||||
|
||||
upload_file=
|
||||
create_file=
|
||||
if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then
|
||||
if [ -f "$__object/parameter/source" ]; then
|
||||
if [ ! -f "$__object/parameter/source" ]; then
|
||||
create_file=1
|
||||
echo create >> "$__messages_out"
|
||||
else
|
||||
source="$(cat "$__object/parameter/source")"
|
||||
if [ "$source" = "-" ]; then
|
||||
source="$__object/stdin"
|
||||
fi
|
||||
|
||||
if [ -f "$source" ]; then
|
||||
local_cksum="$(cksum < "$source")"
|
||||
remote_cksum="$(cat "$__object/explorer/cksum")"
|
||||
|
||||
if [ "$local_cksum" != "$remote_cksum" ]; then
|
||||
echo "$__remote_copy" "$source" "${__target_host}:${destination}"
|
||||
fi
|
||||
else
|
||||
if [ ! -f "$source" ]; then
|
||||
echo "Source \"$source\" does not exist." >&2
|
||||
exit 1
|
||||
else
|
||||
if [ "$type" != "file" ]; then
|
||||
# destination is not a regular file, upload source to replace it
|
||||
upload_file=1
|
||||
else
|
||||
local_cksum="$(cksum < "$source")"
|
||||
remote_cksum="$(cat "$__object/explorer/cksum")"
|
||||
if [ "$local_cksum" != "$remote_cksum" ]; then
|
||||
# destination is a regular file, but not the right one
|
||||
upload_file=1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "$create_file" -o "$upload_file" ]; then
|
||||
# tell gencode-remote that we created or uploaded a file and that it must
|
||||
# set all attributes no matter what the explorer retreived
|
||||
mkdir "$__object/files"
|
||||
touch "$__object/files/set-attributes"
|
||||
|
||||
# upload file to temp location
|
||||
tempfile_template="${destination}.cdist.XXXXXXXXXX"
|
||||
cat << DONE
|
||||
destination_upload="\$($__remote_exec $__target_host "mktemp $tempfile_template")"
|
||||
DONE
|
||||
if [ "$upload_file" ]; then
|
||||
echo upload >> "$__messages_out"
|
||||
cat << DONE
|
||||
$__remote_copy $source ${__target_host}:\$destination_upload
|
||||
DONE
|
||||
fi
|
||||
# move uploaded file into place
|
||||
cat << DONE
|
||||
$__remote_exec $__target_host "rm -rf \"$destination\"; mv \"\$destination_upload\" \"$destination\""
|
||||
DONE
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2013 Steven Armstrong (steven-cdist armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -17,52 +18,77 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# __file is a very basic type, which will probably be reused quite often
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
state_should=present
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
exists="$(cat "$__object/explorer/exists")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
type="$(cat "$__object/explorer/type")"
|
||||
stat_file="$__object/explorer/stat"
|
||||
|
||||
|
||||
get_current_value() {
|
||||
if [ -s "$stat_file" ]; then
|
||||
_name="$1"
|
||||
_value="$2"
|
||||
case "$_value" in
|
||||
[0-9]*)
|
||||
_index=2
|
||||
;;
|
||||
*)
|
||||
_index=3
|
||||
;;
|
||||
esac
|
||||
awk '/'"$_name"':/ { print $'$_index' }' "$stat_file"
|
||||
unset _name _value _index
|
||||
fi
|
||||
}
|
||||
|
||||
set_group() {
|
||||
echo chgrp \"$1\" \"$destination\"
|
||||
echo chgrp $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_owner() {
|
||||
echo chown \"$1\" \"$destination\"
|
||||
echo chown $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_mode() {
|
||||
echo chmod \"$1\" \"$destination\"
|
||||
echo chmod $1 >> "$__messages_out"
|
||||
}
|
||||
|
||||
set_attributes=
|
||||
case "$state_should" in
|
||||
present|exists)
|
||||
# No source? Create empty file
|
||||
if [ ! -f "$__object/parameter/source" ]; then
|
||||
if [ "$exists" = "no" ]; then
|
||||
echo touch \"$destination\"
|
||||
fi
|
||||
fi
|
||||
present|exists)
|
||||
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by
|
||||
# clearing S_ISUID and S_ISGID bits (see chown(2))
|
||||
for attribute in group owner mode; do
|
||||
if [ -f "$__object/parameter/$attribute" ]; then
|
||||
value_should="$(cat "$__object/parameter/$attribute")"
|
||||
|
||||
# Group
|
||||
if [ -f "$__object/parameter/group" ]; then
|
||||
echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\"
|
||||
fi
|
||||
# change 0xxx format to xxx format => same as stat returns
|
||||
if [ "$attribute" = mode ]; then
|
||||
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')"
|
||||
fi
|
||||
|
||||
value_is="$(get_current_value "$attribute" "$value_should")"
|
||||
if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then
|
||||
"set_$attribute" "$value_should"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Owner
|
||||
if [ -f "$__object/parameter/owner" ]; then
|
||||
echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\"
|
||||
fi
|
||||
;;
|
||||
|
||||
# Mode - needs to happen last as a chown/chgrp can alter mode by
|
||||
# clearing S_ISUID and S_ISGID bits (see chown(2))
|
||||
if [ -f "$__object/parameter/mode" ]; then
|
||||
echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\"
|
||||
fi
|
||||
;;
|
||||
|
||||
absent)
|
||||
|
||||
if [ "$exists" = "yes" ]; then
|
||||
echo rm -f \"$destination\"
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
absent)
|
||||
if [ "$type" = "file" ]; then
|
||||
echo rm -f \"$destination\"
|
||||
echo remove >> "$__messages_out"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
|
|
@ -13,6 +13,15 @@ DESCRIPTION
|
|||
This cdist type allows you to create files, remove files and set file
|
||||
attributes on the target.
|
||||
|
||||
If the file already exists on the target, then if it is a:
|
||||
- regular file, and state is:
|
||||
present: replace it with the source file if they are not equal
|
||||
exists: do nothing
|
||||
- symlink: replace it with the source file
|
||||
- directory: replace it with the source file
|
||||
|
||||
In any case, make sure that the file attributes are as specified.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
|
|
@ -41,6 +50,21 @@ source::
|
|||
If not supplied, an empty file or directory will be created.
|
||||
If source is '-' (dash), take what was written to stdin as the file content.
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
chgrp <group>::
|
||||
Changed group membership
|
||||
chown <owner>::
|
||||
Changed owner
|
||||
chmod <mode>::
|
||||
Changed mode
|
||||
create::
|
||||
Empty file was created (no --source specified)
|
||||
remove::
|
||||
File exists, but state is absent, file will be removed by generated code.
|
||||
upload::
|
||||
File was uploaded
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
|
@ -81,5 +105,5 @@ SEE ALSO
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
|
||||
Copyright \(C) 2011-2013 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/__file/parameter/default/state
Normal file
1
cdist/conf/type/__file/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
5
cdist/conf/type/__git/explorer/group
Normal file
5
cdist/conf/type/__git/explorer/group
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
destination="/$__object_id/.git"
|
||||
|
||||
stat --print "%G" ${destination} 2>/dev/null || exit 0
|
||||
5
cdist/conf/type/__git/explorer/owner
Normal file
5
cdist/conf/type/__git/explorer/owner
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
destination="/$__object_id/.git"
|
||||
|
||||
stat --print "%U" ${destination} 2>/dev/null || exit 0
|
||||
|
|
@ -20,21 +20,39 @@
|
|||
#
|
||||
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
state_should=present
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
owner_is="$(cat "$__object/explorer/owner")"
|
||||
group_is="$(cat "$__object/explorer/group")"
|
||||
|
||||
branch=master
|
||||
[ -f "$__object/parameter/branch" ] && branch="$(cat "$__object/parameter/branch")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
branch="$(cat "$__object/parameter/branch")"
|
||||
|
||||
source="$(cat "$__object/parameter/source")"
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
[ "$state_should" = "$state_is" ] && exit 0
|
||||
owner="$(cat "$__object/parameter/owner")"
|
||||
group="$(cat "$__object/parameter/group")"
|
||||
mode="$(cat "$__object/parameter/mode")"
|
||||
|
||||
[ "$state_should" = "$state_is" -a \
|
||||
"$owner" = "$owner_is" -a \
|
||||
"$group" = "$group_is" -a \
|
||||
-n "$mode" ] && exit 0
|
||||
|
||||
case $state_should in
|
||||
present)
|
||||
echo git clone --quiet --branch "$branch" "$source" "$destination"
|
||||
|
||||
if [ "$state_should" != "$state_is" ]; then
|
||||
echo git clone --quiet --branch "$branch" "$source" "$destination"
|
||||
fi
|
||||
if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \
|
||||
\( -n "$group" -a "$group_is" != "$group" \) ]; then
|
||||
echo chown -R "${owner}:${group}" "$destination"
|
||||
fi
|
||||
if [ -n "$mode" ]; then
|
||||
echo chmod -R "$mode" "$destination"
|
||||
fi
|
||||
;;
|
||||
# Handled in manifest
|
||||
absent)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,16 @@ state::
|
|||
|
||||
branch::
|
||||
Create this branch by checking out the remote branch of this name
|
||||
Default branch is "master"
|
||||
|
||||
group::
|
||||
Group to chgrp to.
|
||||
|
||||
mode::
|
||||
Unix permissions, suitable for chmod.
|
||||
|
||||
owner::
|
||||
User to chown to.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
|
|
|||
|
|
@ -23,17 +23,13 @@
|
|||
|
||||
__package git --state present
|
||||
|
||||
state_should=present
|
||||
[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
[ -f "$__object/parameter/owner" ] && dirparams="$dirparams --owner $(cat "$__object/parameter/owner")"
|
||||
[ -f "$__object/parameter/group" ] && dirparams="$dirparams --group $(cat "$__object/parameter/group")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
|
||||
# Let __directory handle removal of git repos
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
__directory "$__object_id" --state present $dirparams --recursive
|
||||
:
|
||||
;;
|
||||
|
||||
absent)
|
||||
|
|
|
|||
1
cdist/conf/type/__git/parameter/default/branch
Normal file
1
cdist/conf/type/__git/parameter/default/branch
Normal file
|
|
@ -0,0 +1 @@
|
|||
master
|
||||
1
cdist/conf/type/__git/parameter/default/group
Normal file
1
cdist/conf/type/__git/parameter/default/group
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
cdist/conf/type/__git/parameter/default/mode
Normal file
1
cdist/conf/type/__git/parameter/default/mode
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
cdist/conf/type/__git/parameter/default/owner
Normal file
1
cdist/conf/type/__git/parameter/default/owner
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
cdist/conf/type/__git/parameter/default/state
Normal file
1
cdist/conf/type/__git/parameter/default/state
Normal file
|
|
@ -0,0 +1 @@
|
|||
present
|
||||
|
|
@ -2,3 +2,4 @@ state
|
|||
branch
|
||||
group
|
||||
owner
|
||||
mode
|
||||
|
|
|
|||
|
|
@ -58,10 +58,12 @@ if grep -q "^${name}:" "$__object/explorer/group"; then
|
|||
|
||||
if [ "$new_value" != "$current_value" ]; then
|
||||
set -- "$@" "$proparg" \"$new_value\"
|
||||
echo change $property $new_value $current_value >> "$__messages_out"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
echo mod >> "$__messages_out"
|
||||
case $os in
|
||||
freebsd)
|
||||
echo pw group mod "$@" "$name"
|
||||
|
|
@ -72,6 +74,7 @@ if grep -q "^${name}:" "$__object/explorer/group"; then
|
|||
esac
|
||||
fi
|
||||
else
|
||||
echo add >> "$__messages_out"
|
||||
for property in $(ls .); do
|
||||
new_value="$(cat "$property")"
|
||||
if [ "$os" = "freebsd" ]; then
|
||||
|
|
@ -95,6 +98,7 @@ else
|
|||
fi
|
||||
|
||||
set -- "$@" "$proparg" \"$new_value\"
|
||||
echo set $property $new_value >> "$__messages_out"
|
||||
done
|
||||
|
||||
case $os in
|
||||
|
|
|
|||
|
|
@ -26,6 +26,18 @@ password::
|
|||
see above
|
||||
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
mod::
|
||||
group is modified
|
||||
add::
|
||||
New group added
|
||||
change <property> <new_value> <current_value>::
|
||||
Changed group property from current_value to new_value
|
||||
set <property> <new_value>::
|
||||
set property to new value, property was not set bevore
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
|
|
|
|||
24
cdist/conf/type/__hostname/explorer/has_hostnamectl
Executable file
24
cdist/conf/type/__hostname/explorer/has_hostnamectl
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# Check whether system has hostnamectl
|
||||
#
|
||||
|
||||
command -v hostnamectl || true
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
|
@ -18,13 +18,9 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# Check whether file exists or not
|
||||
# Retrieve the contents of /etc/hostname
|
||||
#
|
||||
|
||||
destination="/$__object_id"
|
||||
|
||||
if [ -e "$destination" ]; then
|
||||
echo yes
|
||||
else
|
||||
echo no
|
||||
if [ -f /etc/hostname ]; then
|
||||
cat /etc/hostname
|
||||
fi
|
||||
50
cdist/conf/type/__hostname/gencode-remote
Executable file
50
cdist/conf/type/__hostname/gencode-remote
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/name" ]; then
|
||||
name_should="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name_should="$(echo "${__target_host%%.*}")"
|
||||
fi
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
name_running=$(cat "$__global/explorer/hostname")
|
||||
name_config=$(cat "$__object/explorer/hostname_file")
|
||||
has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
|
||||
|
||||
################################################################################
|
||||
# If everything is ok -> exit
|
||||
#
|
||||
if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# Setup hostname
|
||||
#
|
||||
echo changed >> "$__messages_out"
|
||||
|
||||
if [ "$has_hostnamectl" ]; then
|
||||
echo "hostnamectl set-hostname '$name_should'"
|
||||
else
|
||||
echo "hostname '$name_should'"
|
||||
echo "printf '%s\n' '$name_should' > /etc/hostname"
|
||||
fi
|
||||
52
cdist/conf/type/__hostname/man.text
Normal file
52
cdist/conf/type/__hostname/man.text
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
cdist-type__hostname(7)
|
||||
=======================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__hostname - set the hostname
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Set's the hostname on various operating systems.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
The hostname to set. Defaults to the first segment of __target_host
|
||||
(${__target_host%%.*})
|
||||
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
changed::
|
||||
Changed the hostname
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# take hostname from __target_host
|
||||
__hostname
|
||||
|
||||
# set hostname explicitly
|
||||
__hostname --name some-static-hostname
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2012 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
38
cdist/conf/type/__hostname/manifest
Executable file
38
cdist/conf/type/__hostname/manifest
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
|
||||
not_supported() {
|
||||
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
||||
echo "Please contribute an implementation for it if you can." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
case "$os" in
|
||||
archlinux|debian|ubuntu)
|
||||
# handled in gencode-remote
|
||||
:
|
||||
;;
|
||||
*)
|
||||
not_supported
|
||||
;;
|
||||
esac
|
||||
1
cdist/conf/type/__hostname/parameter/optional
Normal file
1
cdist/conf/type/__hostname/parameter/optional
Normal file
|
|
@ -0,0 +1 @@
|
|||
name
|
||||
48
cdist/conf/type/__iptables_apply/files/init-script
Normal file
48
cdist/conf/type/__iptables_apply/files/init-script
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
# Nico Schottelius
|
||||
# Zürisee, Mon Sep 2 18:38:27 CEST 2013
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: iptables
|
||||
# Required-Start: $local_fs $remote_fs
|
||||
# Required-Stop: $local_fs $remote_fs
|
||||
# X-Start-Before: fail2ban
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Applies iptables ruleset
|
||||
# Description: Applies all rules found in /etc/iptables.d
|
||||
# and saves/restores previous status
|
||||
### END INIT INFO
|
||||
|
||||
|
||||
basedir=/etc/iptables.d
|
||||
status="${basedir}/.pre-start"
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
# Save status
|
||||
iptables-save > "$status"
|
||||
|
||||
# Apply our ruleset
|
||||
cd "$basedir"
|
||||
count="$(ls -1 | wc -l)"
|
||||
|
||||
# Only do something if there are rules
|
||||
if [ "$count" -ge 1 ]; then
|
||||
for rule in *; do
|
||||
echo "Applying iptables rule $rule ..."
|
||||
iptables $(cat "$rule")
|
||||
done
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
# Restore from status before, if there is something to restore
|
||||
if [ -f "$status" ]; then
|
||||
iptables-restore < "$status"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
"$0" stop && "$0" start
|
||||
;;
|
||||
esac
|
||||
3
cdist/conf/type/__iptables_apply/gencode-remote
Normal file
3
cdist/conf/type/__iptables_apply/gencode-remote
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if grep -q "^__file/etc/iptables.d/" "$__messages_in"; then
|
||||
echo /etc/init.d/iptables restart
|
||||
fi
|
||||
42
cdist/conf/type/__iptables_apply/man.text
Normal file
42
cdist/conf/type/__iptables_apply/man.text
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
cdist-type__iptables_apply(7)
|
||||
=============================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__iptables_apply - Apply the rules
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type deploys an init script that triggers
|
||||
the configured rules and also re-applies them on
|
||||
configuration.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
None (__iptables_apply is used by __iptables_rule)
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- cdist-type__iptables_rule(7)
|
||||
- iptables(8)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2013 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
26
cdist/conf/type/__iptables_apply/manifest
Normal file
26
cdist/conf/type/__iptables_apply/manifest
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
|
||||
__file /etc/init.d/iptables \
|
||||
--source "$__type/files/init-script" \
|
||||
--state present \
|
||||
--mode 0755
|
||||
|
||||
require="__file/etc/init.d/iptables" __start_on_boot iptables
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue