From 2ed762cd72d426ff0d25cf21ac7ddb48312297e8 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Thu, 28 Jul 2016 14:48:32 +0200 Subject: [PATCH 01/11] new type __filesystem, first version --- .../type/__filesystem/explorer/blkdev_devname | 38 ++++++++ .../type/__filesystem/explorer/blkdev_fstype | 38 ++++++++ .../type/__filesystem/explorer/blkdev_label | 38 ++++++++ .../__filesystem/explorer/blkdev_mountpoint | 38 ++++++++ cdist/conf/type/__filesystem/gencode-remote | 96 +++++++++++++++++++ cdist/conf/type/__filesystem/man.rst | 79 +++++++++++++++ .../conf/type/__filesystem/parameter/boolean | 1 + .../type/__filesystem/parameter/default/label | 0 .../parameter/default/mkfsoptions | 0 .../conf/type/__filesystem/parameter/optional | 2 + .../conf/type/__filesystem/parameter/required | 2 + docs/changelog | 2 + 12 files changed, 334 insertions(+) create mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_devname create mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_fstype create mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_label create mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_mountpoint create mode 100644 cdist/conf/type/__filesystem/gencode-remote create mode 100644 cdist/conf/type/__filesystem/man.rst create mode 100644 cdist/conf/type/__filesystem/parameter/boolean create mode 100644 cdist/conf/type/__filesystem/parameter/default/label create mode 100644 cdist/conf/type/__filesystem/parameter/default/mkfsoptions create mode 100644 cdist/conf/type/__filesystem/parameter/optional create mode 100644 cdist/conf/type/__filesystem/parameter/required diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_devname b/cdist/conf/type/__filesystem/explorer/blkdev_devname new file mode 100644 index 00000000..30c8409a --- /dev/null +++ b/cdist/conf/type/__filesystem/explorer/blkdev_devname @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2016 - 2016 Daniel Heule (hda at sfs.biz) +# +# 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 . +# + +os=$("$__explorer/os") + +blkdev="$(cat "$__object/parameter/blkdev")" + +case "$os" in + centos|fedora|redhat|suse|gentoo) + if [ ! -x "$(command -v lsblk)" ]; then + echo "lsblk is required for __filesystem type" >&2 + exit 1 + else + echo -n $(lsblk -n -o NAME "$blkdev" 2>/dev/null) + fi + ;; + *) + echo "__filesystem type lacks implementation for os: $os" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_fstype b/cdist/conf/type/__filesystem/explorer/blkdev_fstype new file mode 100644 index 00000000..3f92142f --- /dev/null +++ b/cdist/conf/type/__filesystem/explorer/blkdev_fstype @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2016 - 2016 Daniel Heule (hda at sfs.biz) +# +# 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 . +# + +os=$("$__explorer/os") + +blkdev="$(cat "$__object/parameter/blkdev")" + +case "$os" in + centos|fedora|redhat|suse|gentoo) + if [ ! -x "$(command -v lsblk)" ]; then + echo "lsblk is required for __filesystem type" >&2 + exit 1 + else + echo -n $(lsblk -n -o FSTYPE "$blkdev" 2>/dev/null) + fi + ;; + *) + echo "__filesystem type lacks implementation for os: $os" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_label b/cdist/conf/type/__filesystem/explorer/blkdev_label new file mode 100644 index 00000000..aa227cab --- /dev/null +++ b/cdist/conf/type/__filesystem/explorer/blkdev_label @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2016 - 2016 Daniel Heule (hda at sfs.biz) +# +# 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 . +# + +os=$("$__explorer/os") + +blkdev="$(cat "$__object/parameter/blkdev")" + +case "$os" in + centos|fedora|redhat|suse|gentoo) + if [ ! -x "$(command -v lsblk)" ]; then + echo "lsblk is required for __filesystem type" >&2 + exit 1 + else + echo -n $(lsblk -n -o LABEL "$blkdev" 2>/dev/null) + fi + ;; + *) + echo "__filesystem type lacks implementation for os: $os" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_mountpoint b/cdist/conf/type/__filesystem/explorer/blkdev_mountpoint new file mode 100644 index 00000000..1cef068c --- /dev/null +++ b/cdist/conf/type/__filesystem/explorer/blkdev_mountpoint @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2016 - 2016 Daniel Heule (hda at sfs.biz) +# +# 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 . +# + +os=$("$__explorer/os") + +blkdev="$(cat "$__object/parameter/blkdev")" + +case "$os" in + centos|fedora|redhat|suse|gentoo) + if [ ! -x "$(command -v lsblk)" ]; then + echo "lsblk is required for __filesystem type" >&2 + exit 1 + else + echo -n $(lsblk -n -o MOUNTPOINT "$blkdev" 2>/dev/null) + fi + ;; + *) + echo "__filesystem type lacks implementation for os: $os" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__filesystem/gencode-remote b/cdist/conf/type/__filesystem/gencode-remote new file mode 100644 index 00000000..9d134dcc --- /dev/null +++ b/cdist/conf/type/__filesystem/gencode-remote @@ -0,0 +1,96 @@ +#!/bin/sh +# +# 2016 - 2016 Daniel Heule (hda at sfs.biz) +# +# 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 . +# + + +fstype="$(cat "$__object/parameter/fstype")" +mydev="$(cat "$__object/parameter/blkdev")" + +label="$(cat "$__object/parameter/label")" +mkfsoptions="$(cat "$__object/parameter/mkfsoptions")" + + +if [ -f "$__object/parameter/force" ]; then + # create filesystem even an other filesystem is on disk or the label is not correct, use with caution ! + forcefs="true" +else + forcefs="false" +fi + + +blkdev_devname="$(cat "$__object/explorer/blkdev_devname")" +blkdev_fstype="$(cat "$__object/explorer/blkdev_fstype")" +blkdev_label="$(cat "$__object/explorer/blkdev_label")" +blkdev_mountpoint="$(cat "$__object/explorer/blkdev_mountpoint")" + +if [ -z "$blkdev_devname" ]; then + echo "Specified device $mydev not found on target system" >&2 + exit 1 +fi + +[ "$blkdev_label" = "$label" ] && [ "$blkdev_fstype" = "$fstype" ] && exit 0 + +if [ -n "$blkdev_mountpoint" ]; then + echo "Specified device $mydev is mounted on $blkdev_mountpoint, __filesystem does NOTHING with mountd devices" >&2 + exit 0 +fi + +if [ -n "$blkdev_fstype" ] && [ "$forcefs" != "true" ]; then + if [ "$blkdev_label" != "$label" ]; then + echo "Specified device $mydev has not the spezified label: $blkdev_label, but __filesystem does NOTHING in this case without the --force option" >&2 + exit 0 + fi + if [ "$blkdev_fstype" != "$fstype" ]; then + echo "Specified device $mydev has not the spezified filesystem: $blkdev_fstype, but __filesystem does NOTHING in this case without the --force option" >&2 + exit 0 + fi +fi + + +# ok, all conditions checked, we need to format the device, lets go +opts="$mkfsoptions" +if [ -n "$label" ]; then + opts="$opts -L '$label'" +fi + +case "$fstype" in + ext2|ext3|ext4) + if [ "$forcefs" = "true" ]; then + opts="$opts -F" + fi + echo "mkfs.$fstype $opts /dev/$blkdev_devname" + ;; + btrfs) + if [ "$forcefs" = "true" ]; then + opts="$opts --force" + fi + echo "mkfs.btrfs $opts /dev/$blkdev_devname" + ;; + xfs) + if [ "$forcefs" = "true" ]; then + opts="$opts -f" + fi + echo "mkfs.xfs $opts /dev/$blkdev_devname" + ;; + *) + echo "__filesystem type lacks implementation for filesystem: $fstype" >&2 + exit 1 + ;; +esac +echo "filesystem $fstype on $mydev : /dev/$blkdev_devname created" >> "$__messages_out" diff --git a/cdist/conf/type/__filesystem/man.rst b/cdist/conf/type/__filesystem/man.rst new file mode 100644 index 00000000..c4787d53 --- /dev/null +++ b/cdist/conf/type/__filesystem/man.rst @@ -0,0 +1,79 @@ +cdist-type__filesystem(7) +========================= + +NAME +---- +cdist-type__filesystem - Create Filesystems. + + +DESCRIPTION +----------- +This cdist type allows you to create filesystems on devices. + +If the device is mounted on target, it refuses to do someting. + +If the device has a filesystem other as the specified and/or + the label is not correct, it only make a new filesystem + if you specified --force option + + +REQUIRED PARAMETERS +------------------- +fstype + Filesystem type, for example 'ext3', 'btrfs' or 'xfs' + +blkdev + Blockdevice for filesystem, + On linux, it can be any by lsblk accepted device notation + + for example + /dev/sdx + or /dev/disk/by-xxxx/xxx + or /dev/mapper/xxxx + + +OPTIONAL PARAMETERS +------------------- +label + Label which sould apply on the filesystem + +mkfsoptions + Additional options which are inserted to the mkfs.xxx call. + + +BOOLEAN PARAMETERS +------------------ +force + Normaly, this type does nothing if a filesystem is found + on the target device. If you specify force, its formated + if the filesystem type or label differs from parameters + Warning: This option can easy lead into data loss ! + +MESSAGES +-------- +filesystem on : created + Filesytem was created on + + +EXAMPLES +-------- + +.. code-block:: sh + + # Ensures that device /dev/sdb is formated with xfs + __filesystem dev_sdb --fstype xfs --blkdev /dev/sdb --label Testdisk1 + # The same thing with btrfs and disk spezified by pci path to disk 1:0 on vmware + __filesystem dev_sdb --fstype btrfs --blkdev /dev/disk/by-path/pci-0000:0b:00.0-scsi-0:0:0:0 --label Testdisk2 + # Make sure that a multipath san device has a filesystem ... + __filesystem dev_sdb --fstype xfs --blkdev /dev/mapper/360060e80432f560050202f22000023ff --label Testdisk3 + + +AUTHORS +------- +Daniel Heule + + +COPYING +------- +Copyright \(C) 2016 Daniel Heule. Free use of this software is +granted under the terms of the GNU General Public License version 3 or any later version (GPLv3+). diff --git a/cdist/conf/type/__filesystem/parameter/boolean b/cdist/conf/type/__filesystem/parameter/boolean new file mode 100644 index 00000000..14b33226 --- /dev/null +++ b/cdist/conf/type/__filesystem/parameter/boolean @@ -0,0 +1 @@ +force diff --git a/cdist/conf/type/__filesystem/parameter/default/label b/cdist/conf/type/__filesystem/parameter/default/label new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__filesystem/parameter/default/mkfsoptions b/cdist/conf/type/__filesystem/parameter/default/mkfsoptions new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__filesystem/parameter/optional b/cdist/conf/type/__filesystem/parameter/optional new file mode 100644 index 00000000..0f63435f --- /dev/null +++ b/cdist/conf/type/__filesystem/parameter/optional @@ -0,0 +1,2 @@ +label +mkfsoptions diff --git a/cdist/conf/type/__filesystem/parameter/required b/cdist/conf/type/__filesystem/parameter/required new file mode 100644 index 00000000..33a66684 --- /dev/null +++ b/cdist/conf/type/__filesystem/parameter/required @@ -0,0 +1,2 @@ +fstype +blkdev diff --git a/docs/changelog b/docs/changelog index f73ba776..ba8ee201 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,5 +1,7 @@ Changelog --------- +next: + * New type __filesystem: manage filesystems on devices ( Daniel Heule ) 4.2.2: 2016-07-26 * Core: Fix ssh ControlPath socket file error (Darko Poljak) From 36c20230b89e78780ae3ff6ca9dae52e3799f212 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Fri, 29 Jul 2016 15:27:13 +0200 Subject: [PATCH 02/11] optimize the usage of explorers for __filesystem --- .../type/__filesystem/explorer/blkdev_fstype | 38 ------------------- .../type/__filesystem/explorer/blkdev_label | 38 ------------------- .../__filesystem/explorer/blkdev_mountpoint | 38 ------------------- .../explorer/{blkdev_devname => lsblk} | 3 +- cdist/conf/type/__filesystem/gencode-remote | 9 +++-- 5 files changed, 7 insertions(+), 119 deletions(-) delete mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_fstype delete mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_label delete mode 100644 cdist/conf/type/__filesystem/explorer/blkdev_mountpoint rename cdist/conf/type/__filesystem/explorer/{blkdev_devname => lsblk} (86%) diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_fstype b/cdist/conf/type/__filesystem/explorer/blkdev_fstype deleted file mode 100644 index 3f92142f..00000000 --- a/cdist/conf/type/__filesystem/explorer/blkdev_fstype +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# 2016 - 2016 Daniel Heule (hda at sfs.biz) -# -# 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 . -# - -os=$("$__explorer/os") - -blkdev="$(cat "$__object/parameter/blkdev")" - -case "$os" in - centos|fedora|redhat|suse|gentoo) - if [ ! -x "$(command -v lsblk)" ]; then - echo "lsblk is required for __filesystem type" >&2 - exit 1 - else - echo -n $(lsblk -n -o FSTYPE "$blkdev" 2>/dev/null) - fi - ;; - *) - echo "__filesystem type lacks implementation for os: $os" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_label b/cdist/conf/type/__filesystem/explorer/blkdev_label deleted file mode 100644 index aa227cab..00000000 --- a/cdist/conf/type/__filesystem/explorer/blkdev_label +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# 2016 - 2016 Daniel Heule (hda at sfs.biz) -# -# 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 . -# - -os=$("$__explorer/os") - -blkdev="$(cat "$__object/parameter/blkdev")" - -case "$os" in - centos|fedora|redhat|suse|gentoo) - if [ ! -x "$(command -v lsblk)" ]; then - echo "lsblk is required for __filesystem type" >&2 - exit 1 - else - echo -n $(lsblk -n -o LABEL "$blkdev" 2>/dev/null) - fi - ;; - *) - echo "__filesystem type lacks implementation for os: $os" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_mountpoint b/cdist/conf/type/__filesystem/explorer/blkdev_mountpoint deleted file mode 100644 index 1cef068c..00000000 --- a/cdist/conf/type/__filesystem/explorer/blkdev_mountpoint +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# 2016 - 2016 Daniel Heule (hda at sfs.biz) -# -# 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 . -# - -os=$("$__explorer/os") - -blkdev="$(cat "$__object/parameter/blkdev")" - -case "$os" in - centos|fedora|redhat|suse|gentoo) - if [ ! -x "$(command -v lsblk)" ]; then - echo "lsblk is required for __filesystem type" >&2 - exit 1 - else - echo -n $(lsblk -n -o MOUNTPOINT "$blkdev" 2>/dev/null) - fi - ;; - *) - echo "__filesystem type lacks implementation for os: $os" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__filesystem/explorer/blkdev_devname b/cdist/conf/type/__filesystem/explorer/lsblk similarity index 86% rename from cdist/conf/type/__filesystem/explorer/blkdev_devname rename to cdist/conf/type/__filesystem/explorer/lsblk index 30c8409a..87f95e90 100644 --- a/cdist/conf/type/__filesystem/explorer/blkdev_devname +++ b/cdist/conf/type/__filesystem/explorer/lsblk @@ -28,7 +28,8 @@ case "$os" in echo "lsblk is required for __filesystem type" >&2 exit 1 else - echo -n $(lsblk -n -o NAME "$blkdev" 2>/dev/null) + #echo -n $(lsblk -nd -P -o NAME,FSTYPE,LABEL,MOUNTPOINT "$blkdev" 2>/dev/null) + lsblk -nd -P -o NAME,FSTYPE,LABEL,MOUNTPOINT "$blkdev" 2>/dev/null fi ;; *) diff --git a/cdist/conf/type/__filesystem/gencode-remote b/cdist/conf/type/__filesystem/gencode-remote index 9d134dcc..feb7098d 100644 --- a/cdist/conf/type/__filesystem/gencode-remote +++ b/cdist/conf/type/__filesystem/gencode-remote @@ -34,10 +34,11 @@ else fi -blkdev_devname="$(cat "$__object/explorer/blkdev_devname")" -blkdev_fstype="$(cat "$__object/explorer/blkdev_fstype")" -blkdev_label="$(cat "$__object/explorer/blkdev_label")" -blkdev_mountpoint="$(cat "$__object/explorer/blkdev_mountpoint")" + +blkdev_devname="$(grep -P -o2 'NAME="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_fstype="$(grep -P -o2 'FSTYPE="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_label="$(grep -P -o2 'LABEL="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_mountpoint="$(grep -P -o2 'MOUNTPOINT="\K[^"]*' "$__object/explorer/lsblk")" if [ -z "$blkdev_devname" ]; then echo "Specified device $mydev not found on target system" >&2 From 06d0eabb5ff3a50c9978cf19926e6c91c0da3b21 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 2 Aug 2016 00:58:07 +0200 Subject: [PATCH 03/11] Add new type: __locale_system Merge the best of the proposals from Steven and Carlos --- cdist/conf/type/__locale_system/man.rst | 66 +++++++++++++++++++ cdist/conf/type/__locale_system/manifest | 55 ++++++++++++++++ .../__locale_system/parameter/default/state | 1 + .../__locale_system/parameter/default/value | 1 + .../type/__locale_system/parameter/optional | 2 + 5 files changed, 125 insertions(+) create mode 100644 cdist/conf/type/__locale_system/man.rst create mode 100644 cdist/conf/type/__locale_system/manifest create mode 100644 cdist/conf/type/__locale_system/parameter/default/state create mode 100644 cdist/conf/type/__locale_system/parameter/default/value create mode 100644 cdist/conf/type/__locale_system/parameter/optional diff --git a/cdist/conf/type/__locale_system/man.rst b/cdist/conf/type/__locale_system/man.rst new file mode 100644 index 00000000..fe54c01c --- /dev/null +++ b/cdist/conf/type/__locale_system/man.rst @@ -0,0 +1,66 @@ +cdist-type__locale_system(7) +============================ + +NAME +---- +cdist-type__locale_system - Set system-wide locale + + +DESCRIPTION +----------- +This cdist type allows you to modify system-wide locale. +The name of the locale category is given as the object id +(usually you are probably interested in using LANG) + + +OPTIONAL PARAMETERS +------------------- + +state + present or absent, defaults to present. + If present, sets the locale category to the given value. + If absent, removes the locale category from the system file. + +value + The value for the locale category. + Defaults to en_US.UTF-8. + + +EXAMPLES +-------- + +.. code-block:: sh + + # Set LANG to en_US.UTF-8 + __locale_system LANG + + # Same as above, but more explicit + __locale_system LANG --value en_US.UTF-8 + + # Set category LC_MESSAGES to de_CH.UTF-8 + __locale_system LC_MESSAGES --value de_CH.UTF-8 + + # Remove setting for LC_ALL + __locale_system LC_ALL --state absent + + + +SEE ALSO +-------- +:strong:`locale`\ (1) +:strong:`localedef`\ (1) +:strong:`cdist-type__locale`\ (7) + + +AUTHORS +------- +Steven Armstrong , +Carlos Ortigoza , +Nico Schottelius + + +COPYING +------- +Copyright \(C) 2016 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 or +later (GPLv3+). diff --git a/cdist/conf/type/__locale_system/manifest b/cdist/conf/type/__locale_system/manifest new file mode 100644 index 00000000..02cf48df --- /dev/null +++ b/cdist/conf/type/__locale_system/manifest @@ -0,0 +1,55 @@ +#!/bin/sh +# +# 2012-2016 Steven Armstrong (steven-cdist at armstrong.cc) +# 2016 Carlos Ortigoza (carlos.ortigoza at ungleich.ch) +# 2016 Nico Schottelius (nico.schottelius at ungleich.ch) +# +# 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 . +# +# +# Configure system-wide locale by modifying i18n file. +# + +os=$(cat "$__global/explorer/os") + +case "$os" in + debian|ubuntu) + locale_conf="/etc/default/locale" + ;; + archlinux) + locale_conf="/etc/locale.conf" + ;; + redhat|centos) + locale_conf="/etc/sysconfig/i18n" + ;; + *) + 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 + +__file "$locale_conf" \ + --owner root --group root --mode 644 \ + --state exists + +require="__file/$locale_conf" \ + __key_value "$locale_conf:$__object_id" \ + --file "$locale_conf" \ + --key "$__object_id" \ + --delimiter = \ + --state "$(cat "$__object/parameter/state")" \ + --value "$(cat "$__object/parameter/value")" diff --git a/cdist/conf/type/__locale_system/parameter/default/state b/cdist/conf/type/__locale_system/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__locale_system/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__locale_system/parameter/default/value b/cdist/conf/type/__locale_system/parameter/default/value new file mode 100644 index 00000000..927508f3 --- /dev/null +++ b/cdist/conf/type/__locale_system/parameter/default/value @@ -0,0 +1 @@ +en_US.UTF-8 diff --git a/cdist/conf/type/__locale_system/parameter/optional b/cdist/conf/type/__locale_system/parameter/optional new file mode 100644 index 00000000..d0460d86 --- /dev/null +++ b/cdist/conf/type/__locale_system/parameter/optional @@ -0,0 +1,2 @@ +state +value From 94119003a90a44a998d471e41f0dbd9bffed6a89 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 2 Aug 2016 01:02:47 +0200 Subject: [PATCH 04/11] Reference __locale_system in __locale type --- cdist/conf/type/__locale/man.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__locale/man.rst b/cdist/conf/type/__locale/man.rst index e46d14bd..60a4eacc 100644 --- a/cdist/conf/type/__locale/man.rst +++ b/cdist/conf/type/__locale/man.rst @@ -3,7 +3,7 @@ cdist-type__locale(7) NAME ---- -cdit-type__locale - Configure locales +cdist-type__locale - Configure locales DESCRIPTION @@ -34,7 +34,7 @@ EXAMPLES SEE ALSO -------- -:strong:`locale`\ (1), :strong:`localedef`\ (1) +:strong:`locale`\ (1), :strong:`localedef`\ (1), :strong:`cdist-type__locale_system`\ (7) AUTHORS @@ -44,5 +44,6 @@ Nico Schottelius COPYING ------- -Copyright \(C) 2013-2014 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). +Copyright \(C) 2013-2016 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 or +later (GPLv3+). From 4254046129e2ca66aaa7da712d28e1633ab23ce8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 2 Aug 2016 01:06:29 +0200 Subject: [PATCH 05/11] Update changelog (__locale_system) --- docs/changelog | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/changelog b/docs/changelog index f73ba776..47e6237c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * New type: __locale_system (Steven Armstrong, Carlos Ortigoza, Nico Schottelius) + 4.2.2: 2016-07-26 * Core: Fix ssh ControlPath socket file error (Darko Poljak) * Documentation: Update cdist man page and cdist-references (Darko Poljak) @@ -151,7 +154,7 @@ Changelog * Documentation: Cleanup up, added HTML links (Tomas Pospisek) * Explorer interfaces: Remove test output (Daniel Heule) * Type __jail: Add messaging support (Jake Guffey) - + 3.1.3: 2014-04-29 * New Type: __yum_repo (Steven Armstrong) * Type __hostname: Add support for CentOS (Nico Schottelius) @@ -313,7 +316,7 @@ Changelog * New Type: __postfix_postconf (Steven Armstrong) * New Type: __postfix_postmap (Steven Armstrong) * New Type: __postfix_reload (Steven Armstrong) - * Type __line: Ensure regex does not contain / + * Type __line: Ensure regex does not contain / * Type __ssh_authorized_keys: Bugfix: Preserve ownership (Steven Armstrong) 2.3.3: 2013-09-09 @@ -391,7 +394,7 @@ Changelog * Support for CDIST_PATH (Steven Armstrong) 2.1.0pre8: 2012-11-15 - * Type cleanup: __apt_ppa, __apt_ppa_update_index, __file, + * Type cleanup: __apt_ppa, __apt_ppa_update_index, __file, __ssh_authorized_key, __timezone, all install types (Steven Armstrong) * Types: Remove all parameter changing code (Nico Schottelius) * Type __rvm_ruby: Change parameter "default" to be boolean (Nico Schottelius) @@ -455,7 +458,7 @@ Changelog * Feature __group: Added support for FreeBSD (Jake Guffey) * New Type: __package_zypper (Nico Schottelius) * Feature Types: Initial Support for SuSE Linux (Nico Schottelius) - + 2.0.13: 2012-06-05 * Bugfix __ssh_authorized_key: Ensure it sets proper group (contradict) * Bugfix __addifnosuchline: Fixed quotes/interpolation bug ("a b" became "a b") (Nico Schottelius) @@ -487,7 +490,7 @@ Changelog * Various smaller bugfixes (Chris Lamb) 2.0.9: 2012-03-12 - * Cleanup documentation: Fix environment variable list to be properly + * Cleanup documentation: Fix environment variable list to be properly displayed (Giel van Schijndel) * Cleanup documentation: Some minor corrections * New Type: __package_opkg (Giel van Schijndel) @@ -496,7 +499,7 @@ Changelog * Feature __package: Support for OpenWRT (Giel van Schijndel) * Feature __start_on_boot: Support for OpenWRT (Giel van Schijndel) * Feature __start_on_boot: Support for Amazon Linux (Matt Coddington) - * New Example: Use rsync to backup files (Matt Coddington) + * New Example: Use rsync to backup files (Matt Coddington) * Feature core: Exit non-zero, if configuration failed (Nico Schottelius) * Documentation: Describe how to do templating (Aurélien Bondis) @@ -541,7 +544,7 @@ Changelog (Steven Armstrong, Daniel Maher) * Cleanup: Explicitly require Python >= 3.2 (do not fail implicitly) (Nico Schottelius) * Documentation: (Re)write of the tutorial (Nico Schottelius) - * Feature: __addifnosuchline supports matching on + * Feature: __addifnosuchline supports matching on regular expressions (Daniel Maher) * Feature: __directory, __file, __link: Add --state parameter (Steven Armstrong) From a1ff7555768c74288475651a6e1ae51a17c3221b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 31 Jul 2016 23:50:37 +0200 Subject: [PATCH 06/11] Add type __sysctl - Migrated asciidoc to rst - Changed license to GPLv3+ --- cdist/conf/type/__sysctl/explorer/value | 22 ++++++++++++ cdist/conf/type/__sysctl/gencode-remote | 30 ++++++++++++++++ cdist/conf/type/__sysctl/man.rst | 38 ++++++++++++++++++++ cdist/conf/type/__sysctl/manifest | 39 +++++++++++++++++++++ cdist/conf/type/__sysctl/parameter/required | 1 + 5 files changed, 130 insertions(+) create mode 100755 cdist/conf/type/__sysctl/explorer/value create mode 100755 cdist/conf/type/__sysctl/gencode-remote create mode 100644 cdist/conf/type/__sysctl/man.rst create mode 100755 cdist/conf/type/__sysctl/manifest create mode 100644 cdist/conf/type/__sysctl/parameter/required diff --git a/cdist/conf/type/__sysctl/explorer/value b/cdist/conf/type/__sysctl/explorer/value new file mode 100755 index 00000000..fc85b3d8 --- /dev/null +++ b/cdist/conf/type/__sysctl/explorer/value @@ -0,0 +1,22 @@ +#!/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 . +# + +# get the current runtime value +sysctl -n "$__object_id" || true diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote new file mode 100755 index 00000000..0f3b0b40 --- /dev/null +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -0,0 +1,30 @@ +#!/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 . +# + +value_should="$(cat "$__object/parameter/value")" +value_is="$(cat "$__object/explorer/value")" + +if [ "$value_should" = "$value_is" ]; then + # Nothing to do + exit 0 +fi + +# set the current runtime value +printf 'sysctl -w %s="%s"\n' "$__object_id" "$value_should" diff --git a/cdist/conf/type/__sysctl/man.rst b/cdist/conf/type/__sysctl/man.rst new file mode 100644 index 00000000..e4d5c504 --- /dev/null +++ b/cdist/conf/type/__sysctl/man.rst @@ -0,0 +1,38 @@ +cdist-type__sysctl(7) +===================== + +NAME +---- +cdist-type__sysctl - manage sysctl settings + + +DESCRIPTION +----------- +Manages permanent as well as runtime sysctl settings. +Permament settings are set by managing entries in /etc/sysctl.conf. +Runtime settings are set by directly calling the sysctl executable. + + +REQUIRED PARAMETERS +------------------- +value:: + The value to set for the given key (object_id) + + +EXAMPLES +-------- + +.. code-block:: sh + + __sysctl net.ipv4.ip_forward --value 1 + + +AUTHORS +------- +Steven Armstrong + + +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+). diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest new file mode 100755 index 00000000..dd317806 --- /dev/null +++ b/cdist/conf/type/__sysctl/manifest @@ -0,0 +1,39 @@ +#!/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 . +# + + +os=$(cat "$__global/explorer/os") + +case "$os" in + redhat|centos|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_value "$__object_name" \ + --key "$__object_id" \ + --file /etc/sysctl.conf \ + --value "$(cat "$__object/parameter/value")" \ + --delimiter '=' diff --git a/cdist/conf/type/__sysctl/parameter/required b/cdist/conf/type/__sysctl/parameter/required new file mode 100644 index 00000000..6d4e1507 --- /dev/null +++ b/cdist/conf/type/__sysctl/parameter/required @@ -0,0 +1 @@ +value From ad5ceac5637d876d7420021f4c133ddc6828969a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 31 Jul 2016 23:54:13 +0200 Subject: [PATCH 07/11] Update changelog for new type __sysctl --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 47e6237c..755a5a44 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,8 +1,8 @@ Changelog --------- -next: * New type: __locale_system (Steven Armstrong, Carlos Ortigoza, Nico Schottelius) + * New type: __sysctl (Steven Armstrong) 4.2.2: 2016-07-26 * Core: Fix ssh ControlPath socket file error (Darko Poljak) From 6479ffc4990aaa404d53976d635a9d4e54670e0c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 1 Aug 2016 00:04:02 +0200 Subject: [PATCH 08/11] Really fix the GPLv3+ text --- cdist/conf/type/__sysctl/man.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__sysctl/man.rst b/cdist/conf/type/__sysctl/man.rst index e4d5c504..d5c6495c 100644 --- a/cdist/conf/type/__sysctl/man.rst +++ b/cdist/conf/type/__sysctl/man.rst @@ -35,4 +35,5 @@ Steven Armstrong 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+). +granted under the terms of the GNU General Public License version 3 or +later (GPLv3+). From 13b2443d6b7d4e181fc6dac4b112dd43292ead4d Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Tue, 2 Aug 2016 10:07:27 +0200 Subject: [PATCH 09/11] last cleanups --- cdist/conf/type/__filesystem/explorer/lsblk | 2 +- cdist/conf/type/__filesystem/gencode-remote | 10 +++++----- cdist/conf/type/__filesystem/man.rst | 10 +++++----- cdist/conf/type/__filesystem/parameter/required | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cdist/conf/type/__filesystem/explorer/lsblk b/cdist/conf/type/__filesystem/explorer/lsblk index 87f95e90..a0a87a9d 100644 --- a/cdist/conf/type/__filesystem/explorer/lsblk +++ b/cdist/conf/type/__filesystem/explorer/lsblk @@ -20,7 +20,7 @@ os=$("$__explorer/os") -blkdev="$(cat "$__object/parameter/blkdev")" +blkdev="$(cat "$__object/parameter/device")" case "$os" in centos|fedora|redhat|suse|gentoo) diff --git a/cdist/conf/type/__filesystem/gencode-remote b/cdist/conf/type/__filesystem/gencode-remote index feb7098d..66c25ef0 100644 --- a/cdist/conf/type/__filesystem/gencode-remote +++ b/cdist/conf/type/__filesystem/gencode-remote @@ -20,7 +20,7 @@ fstype="$(cat "$__object/parameter/fstype")" -mydev="$(cat "$__object/parameter/blkdev")" +mydev="$(cat "$__object/parameter/device")" label="$(cat "$__object/parameter/label")" mkfsoptions="$(cat "$__object/parameter/mkfsoptions")" @@ -35,10 +35,10 @@ fi -blkdev_devname="$(grep -P -o2 'NAME="\K[^"]*' "$__object/explorer/lsblk")" -blkdev_fstype="$(grep -P -o2 'FSTYPE="\K[^"]*' "$__object/explorer/lsblk")" -blkdev_label="$(grep -P -o2 'LABEL="\K[^"]*' "$__object/explorer/lsblk")" -blkdev_mountpoint="$(grep -P -o2 'MOUNTPOINT="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_devname="$(grep -P -o 'NAME="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_fstype="$(grep -P -o 'FSTYPE="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_label="$(grep -P -o 'LABEL="\K[^"]*' "$__object/explorer/lsblk")" +blkdev_mountpoint="$(grep -P -o 'MOUNTPOINT="\K[^"]*' "$__object/explorer/lsblk")" if [ -z "$blkdev_devname" ]; then echo "Specified device $mydev not found on target system" >&2 diff --git a/cdist/conf/type/__filesystem/man.rst b/cdist/conf/type/__filesystem/man.rst index c4787d53..25c2eeda 100644 --- a/cdist/conf/type/__filesystem/man.rst +++ b/cdist/conf/type/__filesystem/man.rst @@ -22,7 +22,7 @@ REQUIRED PARAMETERS fstype Filesystem type, for example 'ext3', 'btrfs' or 'xfs' -blkdev +device Blockdevice for filesystem, On linux, it can be any by lsblk accepted device notation @@ -51,7 +51,7 @@ force MESSAGES -------- -filesystem on : created +filesystem on : created Filesytem was created on @@ -61,11 +61,11 @@ EXAMPLES .. code-block:: sh # Ensures that device /dev/sdb is formated with xfs - __filesystem dev_sdb --fstype xfs --blkdev /dev/sdb --label Testdisk1 + __filesystem dev_sdb --fstype xfs --device /dev/sdb --label Testdisk1 # The same thing with btrfs and disk spezified by pci path to disk 1:0 on vmware - __filesystem dev_sdb --fstype btrfs --blkdev /dev/disk/by-path/pci-0000:0b:00.0-scsi-0:0:0:0 --label Testdisk2 + __filesystem dev_sdb --fstype btrfs --device /dev/disk/by-path/pci-0000:0b:00.0-scsi-0:0:0:0 --label Testdisk2 # Make sure that a multipath san device has a filesystem ... - __filesystem dev_sdb --fstype xfs --blkdev /dev/mapper/360060e80432f560050202f22000023ff --label Testdisk3 + __filesystem dev_sdb --fstype xfs --device /dev/mapper/360060e80432f560050202f22000023ff --label Testdisk3 AUTHORS diff --git a/cdist/conf/type/__filesystem/parameter/required b/cdist/conf/type/__filesystem/parameter/required index 33a66684..480e3669 100644 --- a/cdist/conf/type/__filesystem/parameter/required +++ b/cdist/conf/type/__filesystem/parameter/required @@ -1,2 +1,2 @@ fstype -blkdev +device From 8747474fd577eaa6d3ebdb117da02a21915ecf7b Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Tue, 2 Aug 2016 11:06:17 +0200 Subject: [PATCH 10/11] device now defaults to object_id --- cdist/conf/type/__filesystem/explorer/lsblk | 6 +++++- cdist/conf/type/__filesystem/gencode-remote | 7 ++++++- cdist/conf/type/__filesystem/man.rst | 11 ++++++----- cdist/conf/type/__filesystem/parameter/optional | 1 + cdist/conf/type/__filesystem/parameter/required | 1 - 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/cdist/conf/type/__filesystem/explorer/lsblk b/cdist/conf/type/__filesystem/explorer/lsblk index a0a87a9d..9ae544ac 100644 --- a/cdist/conf/type/__filesystem/explorer/lsblk +++ b/cdist/conf/type/__filesystem/explorer/lsblk @@ -20,7 +20,11 @@ os=$("$__explorer/os") -blkdev="$(cat "$__object/parameter/device")" +if [ -f "$__object/parameter/device" ]; then + blkdev="$(cat "$__object/parameter/device")" +else + blkdev="$__object_id" +fi case "$os" in centos|fedora|redhat|suse|gentoo) diff --git a/cdist/conf/type/__filesystem/gencode-remote b/cdist/conf/type/__filesystem/gencode-remote index 66c25ef0..3ca1c498 100644 --- a/cdist/conf/type/__filesystem/gencode-remote +++ b/cdist/conf/type/__filesystem/gencode-remote @@ -20,7 +20,12 @@ fstype="$(cat "$__object/parameter/fstype")" -mydev="$(cat "$__object/parameter/device")" + +if [ -f "$__object/parameter/device" ]; then + mydev="$(cat "$__object/parameter/device")" +else + mydev="$__object_id" +fi label="$(cat "$__object/parameter/label")" mkfsoptions="$(cat "$__object/parameter/mkfsoptions")" diff --git a/cdist/conf/type/__filesystem/man.rst b/cdist/conf/type/__filesystem/man.rst index 25c2eeda..c69cc839 100644 --- a/cdist/conf/type/__filesystem/man.rst +++ b/cdist/conf/type/__filesystem/man.rst @@ -22,8 +22,12 @@ REQUIRED PARAMETERS fstype Filesystem type, for example 'ext3', 'btrfs' or 'xfs' + + +OPTIONAL PARAMETERS +------------------- device - Blockdevice for filesystem, + Blockdevice for filesystem, Defaults to object_id. On linux, it can be any by lsblk accepted device notation for example @@ -31,9 +35,6 @@ device or /dev/disk/by-xxxx/xxx or /dev/mapper/xxxx - -OPTIONAL PARAMETERS -------------------- label Label which sould apply on the filesystem @@ -61,7 +62,7 @@ EXAMPLES .. code-block:: sh # Ensures that device /dev/sdb is formated with xfs - __filesystem dev_sdb --fstype xfs --device /dev/sdb --label Testdisk1 + __filesystem /dev/sdb --fstype xfs --label Testdisk1 # The same thing with btrfs and disk spezified by pci path to disk 1:0 on vmware __filesystem dev_sdb --fstype btrfs --device /dev/disk/by-path/pci-0000:0b:00.0-scsi-0:0:0:0 --label Testdisk2 # Make sure that a multipath san device has a filesystem ... diff --git a/cdist/conf/type/__filesystem/parameter/optional b/cdist/conf/type/__filesystem/parameter/optional index 0f63435f..79dddc21 100644 --- a/cdist/conf/type/__filesystem/parameter/optional +++ b/cdist/conf/type/__filesystem/parameter/optional @@ -1,2 +1,3 @@ +device label mkfsoptions diff --git a/cdist/conf/type/__filesystem/parameter/required b/cdist/conf/type/__filesystem/parameter/required index 480e3669..98f8b69f 100644 --- a/cdist/conf/type/__filesystem/parameter/required +++ b/cdist/conf/type/__filesystem/parameter/required @@ -1,2 +1 @@ fstype -device From 67429479f09b3607e0e8b92ca6dd85654e72a4d9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 5 Aug 2016 12:31:36 +0200 Subject: [PATCH 11/11] Remove very old notes Not up-to-date anymore and might be misleading. --- docs/dev/fancy-ideas | 17 ---- docs/dev/git-post-commit-hook | 108 ------------------------ docs/dev/show_all_exported_variables | 25 ------ docs/dev/sync-to-testhost | 28 ------- docs/dev/todo/3.0 | 1 - docs/dev/todo/niconext | 25 ------ docs/dev/todo/performance-ideas | 3 - docs/dev/todo/steven | 118 --------------------------- docs/dev/todo/tests | 27 ------ 9 files changed, 352 deletions(-) delete mode 100644 docs/dev/fancy-ideas delete mode 100755 docs/dev/git-post-commit-hook delete mode 100755 docs/dev/show_all_exported_variables delete mode 100755 docs/dev/sync-to-testhost delete mode 100644 docs/dev/todo/3.0 delete mode 100644 docs/dev/todo/niconext delete mode 100644 docs/dev/todo/steven delete mode 100644 docs/dev/todo/tests diff --git a/docs/dev/fancy-ideas b/docs/dev/fancy-ideas deleted file mode 100644 index 8ee290cd..00000000 --- a/docs/dev/fancy-ideas +++ /dev/null @@ -1,17 +0,0 @@ -== types with namespaces == -- allow types to have namespaces, e.g. - __path/my/type -implemented as a proof of concept at: -https://github.com/asteven/cdist/tree/type-namespaces - - - -Execute all global explorers only when needed #286 - -My intention is to create a brunch of global explorer which are of use in some cases and makes cdist more userfriendly. But now, all global explorers are allways executed, even the return value of the explorers is never used. - -I think a possible approach can be to replace the result files with pipes, and on first read of the pipe, the explorer is executed by the core, all following read calls from the pipe are answered from the core with the result of the first real execute of the explorer. - -So cdist can have an unlimited number of global explorers and only used explorers are executed on the target host, all other explorers laying around are simply ignored. - -Also a possible approach would be to create a new explorer type (dynamic explorers) which are sitting in a different directory to (for example dynexploer) and only this ones are executed with the conditional approach explained above. So the overhead to create pipes and monitor it is only in place on explorers which are not interesting for everyone ... diff --git a/docs/dev/git-post-commit-hook b/docs/dev/git-post-commit-hook deleted file mode 100755 index b16caa2a..00000000 --- a/docs/dev/git-post-commit-hook +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env bash -# Distributed under the terms of the GNU General Public License v2 -# Copyright (c) 2006 Fernando J. Pereda -# -# Git CIA bot in bash. (no, not the POSIX shell, bash). -# It is *heavily* based on Git ciabot.pl by Petr Baudis. -# -# It is meant to be run either on a post-commit hook or in an update -# hook: -# -# post-commit: It parses latest commit and current HEAD to get the -# information it needs. -# -# update: You have to call it once per merged commit: -# -# refname=$1 -# oldhead=$2 -# newhead=$3 -# for merged in $(git rev-list ${oldhead}..${newhead} | tac) ; do -# /path/to/ciabot.bash ${refname} ${merged} -# done -# - -# The project as known to CIA -project="cdist" - -# Set to true if you want the full log to be sent -noisy=false - -# Addresses for the e-mail -from="nico-cia.vc@schottelius.org" -to="cia@cia.vc" - -# SMTP client to use -sendmail="/usr/sbin/sendmail -f ${from} ${to}" - -# Changeset URL -url="http://git.schottelius.org/?p=${project};a=commit;h=@@sha1@@" - -# You shouldn't be touching anything else. -if [[ $# = 0 ]] ; then - refname=$(git symbolic-ref HEAD 2>/dev/null) - merged=$(git rev-parse HEAD) -else - refname=$1 - merged=$2 -fi - -refname=${refname##refs/heads/} - -gitver=$(git --version) -gitver=${gitver##* } - -rev=$(git describe ${merged} 2>/dev/null) -[[ -z ${rev} ]] && rev=${merged:0:12} - -rawcommit=$(git cat-file commit ${merged}) - -author=$(sed -n -e '/^author .*<\([^@]*\).*$/s--\1-p' \ - <<< "${rawcommit}") - -logmessage=$(sed -e '1,/^$/d' <<< "${rawcommit}") -${noisy} || logmessage=$(head -n 1 <<< "${logmessage}") -logmessage=${logmessage//&/&} -logmessage=${logmessage///>} - -ts=$(sed -n -e '/^author .*> \([0-9]\+\).*$/s--\1-p' \ - <<< "${rawcommit}") - -out=" - - - CIA Bash client for Git - ${gitver} - http://dev.gentoo.org/~ferdy/stuff/ciabot.bash - - - ${project} - ${refname} - - ${ts} - - - ${author} - ${rev} - - $(git diff-tree -r --name-only ${merged} | - sed -e '1d' -e 's-.*-&-') - - -${logmessage} - - ${url//@@sha1@@/${merged}} - - -" - -${sendmail} << EOM -Message-ID: <${merged:0:12}.${author}@${project}> -From: ${from} -To: ${to} -Content-type: text/xml -Subject: DeliverXML -${out} -EOM - -# vim: set tw=70 : diff --git a/docs/dev/show_all_exported_variables b/docs/dev/show_all_exported_variables deleted file mode 100755 index 18acceca..00000000 --- a/docs/dev/show_all_exported_variables +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# 2010-2011 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 . -# -# -# Generate documentation of exported variables -# - - -cat bin/* | awk '/^export/ { print $2 }' diff --git a/docs/dev/sync-to-testhost b/docs/dev/sync-to-testhost deleted file mode 100755 index cc59eb8d..00000000 --- a/docs/dev/sync-to-testhost +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# -# 2011 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 . -# -# -# Sync repo to testhosts -# - -dirs="cdist cdist-nutzung" - -for dir in $dirs; do - rsync -av --delete /home/users/nico/p/$dir/ root@rnic01:$dir -done diff --git a/docs/dev/todo/3.0 b/docs/dev/todo/3.0 deleted file mode 100644 index 97699879..00000000 --- a/docs/dev/todo/3.0 +++ /dev/null @@ -1 +0,0 @@ -- remove __self and all references to it diff --git a/docs/dev/todo/niconext b/docs/dev/todo/niconext deleted file mode 100644 index aa5f6001..00000000 --- a/docs/dev/todo/niconext +++ /dev/null @@ -1,25 +0,0 @@ -- introduce default parameters - - valid for optional parameters only - - stored in parameter/default/$name - - - when/where to save? in emulator? - - read vi fsproperty? - -- cleanup object_id handling - - have a look at singletons - -- update/create docs - - cdist-cache:: - How to get use information about the hosts we have been working on [advanced] - - cdist-scaling-tuning:: - How to scale out with cdist and which tunings to apply. [advanced] - - cdist-installation - How to use cdist to install hosts - - check speech publishing - - and speeches, which may be outdated as well - - Create new video for cdist 2.x - http://www.youtube.com/watch?v=PRMjzy48eTI - - - exec flag is not true for manifest anymore - - SSH HINTS - ssh agent - diff --git a/docs/dev/todo/performance-ideas b/docs/dev/todo/performance-ideas index bbbfe427..0320affa 100644 --- a/docs/dev/todo/performance-ideas +++ b/docs/dev/todo/performance-ideas @@ -1,6 +1,3 @@ -- Migrate scripts from bin/* to functions in bin/cdist-deploy-to - Use one pipe-shell for type execution - Parallelise gencode and code-run of all objects - Diff against local cache only instead of real target -- Use only one ssh session? - - Can be indirectly improved via ssh config already! diff --git a/docs/dev/todo/steven b/docs/dev/todo/steven deleted file mode 100644 index 2aacaa42..00000000 --- a/docs/dev/todo/steven +++ /dev/null @@ -1,118 +0,0 @@ -autorequire: - - objects defined in type manifests should be automatically prerequisites of the current object - - __foo/some-id - __other other-id --state present - => require="__other/other-id" __foo/some-id - - -metaparameters: - - steal the metaparameters from puppet: - - # I have to be there before the other one - __directory /etc/ssh \ - --before __file/etc/ssh/sshd_config - - # the other one has to be there before me - __file /etc/ssh/sshd_config \ - --after __directory/etc/ssh - - # if I change, tell the other one about it - __file /etc/ssh/sshd_config \ - --notify __init_script/etc/rc.d/sshd - - # whenever the other one changes, I want to know - __init_script /etc/rc.d/sshd \ - --subscribe __file/etc/ssh/sshd_config - - - how does a type react to a received 'event'? - - maybe something like: - __some_type/ - manifest - ... - gencode-refresh - ... - - gencode-refresh -> code-refresh -> ssh $target sh -e code-refresh - - - - -logging: - - logging from type emulator without clobbering stdout - maybe implement logging server as described here [1] - [1] http://docs.python.org/py3k/howto/logging-cookbook.html#configuration-server-example - - - use different logger to limit output to current area of interest, - e.g. - explorer.$target_host: explorer related messages for the run for $target_host - manifest.$target_host: manifest related messages for the run for $target_host - ... - then one could filter e.g. on explorer.* - - - more granular debug output, - [2] http://blog.ooz.ie/2011/03/python-logging-extending-standard.html - - - -tests: - - __init__(): - - sets up env: __target_host - - run_initial_manifest(): - - parameter is actually used (from __init__) - - ensure changing the manifest actually runs a different manifest - -> give ConfigInstall Constructor different manifest - -> different manifest is executed. - - test all submitted (from core to type manifest) variables: - - ENVIRONMENT - - they are set - - they contain the correct values - - run_type_manifest(): - - test all submitted (from core to type manifest) variables: - - ENVIRONMENT - - they are set - - they contain the correct values - - same tests as for test_initial_manifest_*? - - run_manifest(): - - test all submitted variables: - - ENVIRONMENT - - including __debug, if debug - - they are set - - they contain the correct values - - does $require work? - - check that exception raised, if manifest is not existent - - object_run(): - - ensure no object is run twice - - ensure requirements are taken into account? - - and order of run is adjusted - - check (from extern?) that all needed variables are setup - - ensure no code-{local, remote} is created, - if gencode is not producing code - - ensure THAT code-{local, remote} contains what gencode created - - abort if gencode-* fails - - abort if code-* fails - - abort == raise(FooException) - - gencode-*: ensure ENVIRONMENT is setup correctly - - run_type_explorer() - - ensure ALL type explores have been run - - ensure output is saved to correct path - - ensure a type with {0,1,2} explorers works ? - - none, one, multiple - - ensure ENVIRONMENT is setup correctly - - fails if ANY of the given explorer fails - - run_global_explorers(): - - ensure ALL type explores have been run - - ensure output is saved to correct path - - ensure a type with {0,1,2} explorers works ? - - none, one, multiple - - ensure ENVIRONMENT is setup correctly - - fails if ANY of the given explorer fails - -Code fixes needed: - - - shutil, os.mkdir, etc. everywhere: catch/reraise exceptions correctly diff --git a/docs/dev/todo/tests b/docs/dev/todo/tests deleted file mode 100644 index d2101980..00000000 --- a/docs/dev/todo/tests +++ /dev/null @@ -1,27 +0,0 @@ -Tests needed for config_install: - - cleanup() - - Fail if cache_dir from previous run cannot be deleted - - Fail if cache_dir cannot be created from current out_dir - - filter() - - ensure logformat is changed: target host is prefixed: - LOGLEVEL: target_host: MESSAGE - - link_emulator(): - - ensure that links to ALL types are created - - ensure that links points to correct executable - - i.e. readlink() works - - AND target of readlink is the correct executable - - remote_mkdir() - - is directory created - - remove_remote_path - - is path removed - - transfer_path - - is src to dst transferred? - -emulator: - may only be called with __ as prefix - fail otherwise!