forked from ungleich-public/cdist
Merge branch 'nfs' of https://github.com/asteven/cdist
This commit is contained in:
commit
2a3f294ec0
13 changed files with 379 additions and 0 deletions
42
conf/type/__nfs_client/man.text
Normal file
42
conf/type/__nfs_client/man.text
Normal file
|
@ -0,0 +1,42 @@
|
|||
cdist-type__nfs_client(7)
|
||||
=========================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__nfs_client - nfs client
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Install, start, do whatever is necessary to have a working nfs client.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__nfs_client
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
29
conf/type/__nfs_client/manifest
Executable file
29
conf/type/__nfs_client/manifest
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__package nfs-common --state installed
|
||||
|
||||
require="__package/nfs-common" \
|
||||
__process portmap --state running --start "/etc/init.d/portmap start"
|
||||
|
||||
require="__package/nfs-common" \
|
||||
__process statd --state running \
|
||||
--start "/etc/init.d/statd start" \
|
||||
--name "rpc.statd.*"
|
0
conf/type/__nfs_client/singleton
Normal file
0
conf/type/__nfs_client/singleton
Normal file
41
conf/type/__nfs_export/explorer/entry
Executable file
41
conf/type/__nfs_export/explorer/entry
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
export="$(cat "$__object/parameter/export" 2>/dev/null || echo "/$__object_id")"
|
||||
|
||||
name="$(echo "${export#/}" | sed 's;/;-;g')"
|
||||
if [ -f "/etc/exports.d/$name" ]; then
|
||||
cat "/etc/exports.d/$name"
|
||||
else
|
||||
prefix="#cdist:__nfs_export${export}"
|
||||
suffix="#/cdist:__nfs_export${export}"
|
||||
awk -v prefix="$prefix" -v suffix="$suffix" '{
|
||||
if (index($0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index($0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
print
|
||||
}
|
||||
}' /etc/exports
|
||||
fi
|
||||
|
25
conf/type/__nfs_export/explorer/exports.d
Executable file
25
conf/type/__nfs_export/explorer/exports.d
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
if [ -d /etc/exports.d ]; then
|
||||
echo present
|
||||
else
|
||||
echo absent
|
||||
fi
|
64
conf/type/__nfs_export/gencode-remote
Executable file
64
conf/type/__nfs_export/gencode-remote
Executable file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
exports_d="$(cat "$__object/explorer/exports.d")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is=$(diff -q "$__object/parameter/entry" "$__object/explorer/entry" \
|
||||
&& echo present \
|
||||
|| echo absent
|
||||
)
|
||||
|
||||
if [ "$state_is" != "$state_should" ]; then
|
||||
if [ "$exports_d" != "present" ]; then
|
||||
case "$state_should" in
|
||||
present)
|
||||
cat << DONE
|
||||
cat >> /etc/exports << EOC
|
||||
$(cat "$__object/parameter/entry")
|
||||
EOC
|
||||
DONE
|
||||
;;
|
||||
absent)
|
||||
# defined in type manifest
|
||||
prefix="$(cat "$__object/parameter/prefix")"
|
||||
suffix="$(cat "$__object/parameter/suffix")"
|
||||
cat << DONE
|
||||
cat /etc/exports
|
||||
awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||
{
|
||||
if (index(\$0,prefix)) {
|
||||
triggered=1
|
||||
}
|
||||
if (triggered) {
|
||||
if (index(\$0,suffix)) {
|
||||
triggered=0
|
||||
}
|
||||
} else {
|
||||
print
|
||||
}
|
||||
}' /etc/exports > /etc/exports+
|
||||
mv -f /etc/exports+ /etc/exports
|
||||
DONE
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# re-export if we changed something
|
||||
echo "exportfs -rf"
|
||||
fi
|
55
conf/type/__nfs_export/man.text
Normal file
55
conf/type/__nfs_export/man.text
Normal file
|
@ -0,0 +1,55 @@
|
|||
cdist-type__nfs_export(7)
|
||||
=========================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__nfs_export - manage nfs exports
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to manage entries in /etc/exports.d.
|
||||
For older distributions (currently ubuntu lucid) that don't support
|
||||
/etc/exports.d the entries are merged into the /etc/exports file.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
client::
|
||||
space delimited list of client ip/networks for use in /etc/exports. See exports(5)
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
options::
|
||||
export options for use in /etc/exports. See exports(5)
|
||||
|
||||
export::
|
||||
the directory to export. Defaults to object_id
|
||||
|
||||
state::
|
||||
Either present or absent. Defaults to present.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__nfs_export /local/chroot/lucid-amd64 \
|
||||
--client "192.168.0.1/24 10.0.0.1/16" \
|
||||
--options "ro,async,no_all_squash,no_root_squash,subtree_check"
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
- exports(5)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
49
conf/type/__nfs_export/manifest
Executable file
49
conf/type/__nfs_export/manifest
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# required
|
||||
client="$(cat "$__object/parameter/client")"
|
||||
|
||||
# optional
|
||||
export="$(cat "$__object/parameter/export" 2>/dev/null \
|
||||
|| echo "/$__object_id" | tee "$__object/parameter/export")"
|
||||
options="$(cat "$__object/parameter/options" 2>/dev/null || true)"
|
||||
state="$(cat "$__object/parameter/state" 2>/dev/null \
|
||||
|| echo "present" | tee "$__object/parameter/state")"
|
||||
|
||||
entry="$export"
|
||||
[ -n "$options" ] && entry="$entry -${options}"
|
||||
entry="$entry $client"
|
||||
|
||||
# NOTE: if changed, also change in explorers
|
||||
prefix="#cdist:__nfs_export${export}"
|
||||
suffix="#/cdist:__nfs_export${export}"
|
||||
echo "$prefix" | tee "$__object/parameter/prefix" > "$__object/parameter/entry"
|
||||
echo "$entry" >> "$__object/parameter/entry"
|
||||
echo "$suffix" | tee "$__object/parameter/suffix" >> "$__object/parameter/entry"
|
||||
|
||||
exports_d="$(cat "$__object/explorer/exports.d")"
|
||||
if [ "$exports_d" = "present" ]; then
|
||||
name="$(echo "$export" | sed 's;/;-;g')"
|
||||
__file "/etc/exports.d/$name" \
|
||||
--source "$__object/parameter/entry" \
|
||||
--owner root --group root --mode 644
|
||||
# --state "$state"
|
||||
fi
|
3
conf/type/__nfs_export/parameter/optional
Normal file
3
conf/type/__nfs_export/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
|||
options
|
||||
export
|
||||
state
|
1
conf/type/__nfs_export/parameter/required
Normal file
1
conf/type/__nfs_export/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
client
|
42
conf/type/__nfs_server/man.text
Normal file
42
conf/type/__nfs_server/man.text
Normal file
|
@ -0,0 +1,42 @@
|
|||
cdist-type__nfs_server(7)
|
||||
=========================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__nfs_server - nfs server
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Install, start, do whatever is necessary to have a working nfs server.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
__nfs_server
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Steven Armstrong. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
28
conf/type/__nfs_server/manifest
Executable file
28
conf/type/__nfs_server/manifest
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__nfs_client
|
||||
|
||||
__package nfs-kernel-server --state installed
|
||||
|
||||
require="__package/nfs-kernel-server" \
|
||||
__process nfs-kernel-server --state running \
|
||||
--start "/etc/init.d/portmap start" \
|
||||
--name ".*rpc.mountd.*"
|
0
conf/type/__nfs_server/singleton
Normal file
0
conf/type/__nfs_server/singleton
Normal file
Loading…
Reference in a new issue