add __postfix* types

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2013-09-24 15:54:14 +02:00
parent 58f19df386
commit 97a8793fdd
27 changed files with 652 additions and 0 deletions

View File

@ -0,0 +1,42 @@
cdist-type__postfix(7)
======================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__postfix - install postfix
DESCRIPTION
-----------
This space intentionally left blank.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
None.
EXAMPLES
--------
--------------------------------------------------------------------------------
__postfix
--------------------------------------------------------------------------------
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).

View File

@ -0,0 +1,33 @@
#!/bin/sh
#
# 2012 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|archlinux)
__package postfix --state present
;;
*)
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
;;
esac

View File

View File

@ -0,0 +1,39 @@
#!/bin/sh
#
# 2011 - 2012 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/>.
#
config="/etc/postfix/master.cf"
# no master.cf, nothing we could do
[ -f "$config" ] || exit 0
# NOTE: keep variables in sync in manifest,explorer,gencode-*
prefix="#cdist:$__object_name"
suffix="#/cdist:$__object_name"
awk -v prefix="$prefix" -v suffix="$suffix" '{
if (index($0,prefix)) {
triggered=1
}
if (triggered) {
if (index($0,suffix)) {
triggered=0
}
print
}
}' "$config"

View File

@ -0,0 +1,76 @@
#!/bin/sh
#
# 2012 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/>.
#
config="/etc/postfix/master.cf"
entry="$__object/files/entry"
state_should="$(cat "$__object/parameter/state")"
if [ ! -s "$__object/explorer/entry" ]; then
state_is='absent'
else
state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \
&& echo present \
|| echo changed
)
fi
if [ "$state_should" = "$state_is" ]; then
# Nothing to do, move along
exit 0
fi
remove_entry() {
# NOTE: keep variables in sync in manifest/explorer/gencode-*
prefix="#cdist:$__object_name"
suffix="#/cdist:$__object_name"
cat << DONE
tmpfile=\$(mktemp ${config}.cdist.XXXXXXXXXX)
awk -v prefix="$prefix" -v suffix="$suffix" '
{
if (index(\$0,prefix)) {
triggered=1
}
if (triggered) {
if (index(\$0,suffix)) {
triggered=0
}
} else {
print
}
}' "$config" > "\$tmpfile"
mv -f "\$tmpfile" "$config"
DONE
}
case "$state_should" in
present)
if [ "$state_is" = "changed" ]; then
remove_entry
fi
cat << DONE
cat >> "$config" << ${__type##*/}_DONE
$(cat "$entry")
${__type##*/}_DONE
DONE
;;
absent)
remove_entry
;;
esac

View File

@ -0,0 +1,73 @@
cdist-type__postfix_master(7)
=============================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__postfix_master - configure postfix master.cf
DESCRIPTION
-----------
See master(5) for more information.
REQUIRED PARAMETERS
-------------------
type::
See master(5)
command::
See master(5)
BOOLEAN PARAMETERS
------------------
noreload::
don't reload postfix after changes
OPTIONAL PARAMETERS
-------------------
state::
present or absent, defaults to present
service::
private::
unpriv::
chroot::
wakeup::
maxproc::
option::
Pass an option to a service. Same as using -o in master.cf.
Can be specified multiple times.
comment::
a textual comment to add with the master.cf entry
EXAMPLES
--------
--------------------------------------------------------------------------------
__postfix_master smtp --type inet --command smtpd
__postfix_master smtp --type inet --chroot y --command smtpd \
--option smtpd_enforce_tls=yes \
--option smtpd_sasl_auth_enable=yes \
--option smtpd_client_restrictions=permit_sasl_authenticated,reject
__postfix_master submission --type inet --command smtpd \
--comment "Run alternative smtp on submission port"
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- master(5)
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).

View File

@ -0,0 +1,81 @@
#!/bin/sh
#
# 2012 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|archlinux)
:
;;
*)
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
;;
esac
# Default to object_id
service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")"
state="$(cat "$__object/parameter/state")"
# NOTE: keep variables in sync in manifest,explorer,gencode-*
prefix="#cdist:$__object_name"
suffix="#/cdist:$__object_name"
# Generate entry for inclusion in master.cf
mkdir "$__object/files"
entry="$__object/files/entry"
(
echo "$prefix"
if [ -f "$__object/parameter/comment" ]; then
echo "# $(cat "$__object/parameter/comment")"
fi
printf "%s " "$service"
printf "%s " "$type"
for parameter in type private unpriv chroot wakeup maxproc; do
printf "%s " "$(cat "$__object/parameter/$parameter")"
done
command="$(cat "$__object/parameter/command")"
# ensure we have a trailing newline
echo "$command"
options="$(cat "$__object/parameter/option" 2>/dev/null || true)"
for option in $options; do
echo " -o $option"
done
echo "$suffix"
) > "$entry"
# Reload postfix after changes
if [ ! -f "$__object/parameter/noreload" ]; then
state_should="$(cat "$__object/parameter/state")"
if [ ! -s "$__object/explorer/entry" ]; then
state_is='absent'
else
state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \
&& echo present \
|| echo changed
)
fi
if [ "$state_is" != "$state_should" ]; then
require="$__object_name" __postfix_reload
fi
fi

View File

@ -0,0 +1 @@
noreload

View File

@ -0,0 +1 @@
-

View File

@ -0,0 +1 @@
-

View File

@ -0,0 +1 @@
-

View File

@ -0,0 +1 @@
present

View File

@ -0,0 +1 @@
-

View File

@ -0,0 +1 @@
-

View File

@ -0,0 +1,9 @@
service
private
unpriv
chroot
wakeup
maxproc
option
comment
state

View File

@ -0,0 +1,2 @@
type
command

View File

@ -0,0 +1,37 @@
#!/bin/sh
#
# 2012 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=$("$__explorer/os")
case "$os" in
ubuntu|debian|archlinux)
:
;;
*)
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
;;
esac
key="$(cat "$__object/parameter/key" 2>/dev/null || echo "$__object_id")"
postconf -h "$key"

View File

@ -0,0 +1,60 @@
#!/bin/sh
#
# 2012 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|archlinux)
:
;;
*)
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
;;
esac
state_should="$(cat "$__object/parameter/state")"
if [ ! -s "$__object/explorer/value" ]; then
state_is='absent'
else
state_is=$(diff -q "$__object/parameter/value" "$__object/explorer/value" >/dev/null \
&& echo present \
|| echo changed
)
fi
if [ "$state_should" = "$state_is" ]; then
# Nothing to do, move along
exit 0
fi
key="$(cat "$__object/parameter/key" 2>/dev/null || echo "$__object_id")"
value="$(cat "$__object/parameter/value")"
case "$state_should" in
absent)
# revert parameter to its default value
echo "postconf -# $key"
;;
present)
echo "postconf -e '$key=$value'"
;;
esac

View File

@ -0,0 +1,51 @@
cdist-type__postfix_postconf(7)
===============================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__postfix_postconf - configure postfix main.cf
DESCRIPTION
-----------
See postconf(5) for possible keys and values.
Note that this type directly runs the postconf executable.
It does not make changes to /etc/postfix/main.cf itself.
REQUIRED PARAMETERS
-------------------
value::
the value for the postfix parameter
OPTIONAL PARAMETERS
-------------------
key::
the name of the parameter. Defaults to __object_id
EXAMPLES
--------
--------------------------------------------------------------------------------
__postfix_postconf mydomain --value somedomain.com
__postfix_postconf bind-to-special-ip --key smtp_bind_address --value 127.0.0.5
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- postconf(5)
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).

View File

@ -0,0 +1 @@
present

View File

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

View File

@ -0,0 +1 @@
value

View File

@ -0,0 +1,21 @@
#!/bin/sh
#
# 2012 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/>.
#
echo "postmap /$__object_id"

View File

@ -0,0 +1,42 @@
cdist-type__postfix_postmap(7)
==============================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__postfix_postmap - run postmap on the given file
DESCRIPTION
-----------
This space intentionally left blank.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
None.
EXAMPLES
--------
--------------------------------------------------------------------------------
__postfix_postmap /etc/postfix/generic
--------------------------------------------------------------------------------
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).

View File

@ -0,0 +1,33 @@
#!/bin/sh
#
# 2012 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|archlinux)
echo "postfix reload"
;;
*)
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
;;
esac

View File

@ -0,0 +1,42 @@
cdist-type__postfix_reload(7)
=============================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__postfix_reload - tell postfix to reload its configuration
DESCRIPTION
-----------
This space intentionally left blank.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
None.
EXAMPLES
--------
--------------------------------------------------------------------------------
__postfix_reload
--------------------------------------------------------------------------------
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).