Merge branch 'issue/283' of git://github.com/asteven/cdist

This commit is contained in:
Nico Schottelius 2014-02-05 23:13:59 +01:00
commit 8afb752908
23 changed files with 524 additions and 0 deletions

View 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

View 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

View 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).

View file

@ -0,0 +1 @@
subkeys.pgp.net

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,3 @@
state
keyid
keyserver

View 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

View 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

View 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).

View 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

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,2 @@
state
name

View file

@ -0,0 +1 @@
uri

View 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).

View 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

View 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

View 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).

View 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

View file

@ -0,0 +1 @@
include-src

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,4 @@
state
distribution
component
arch

View file

@ -0,0 +1 @@
uri