From 4e7c571b7d4e45a3f80f23f26a7ed659691633f5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 May 2011 19:46:05 +0200 Subject: [PATCH 01/10] fixed 19:40 < drothli> telmich: http://www.nico.schottelius.org/software/cdist/man/cdist.html points to http://www.nico.schottelius.org/cdist/ which is a dead link Signed-off-by: Nico Schottelius --- doc/man/man7/cdist.text | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/man7/cdist.text b/doc/man/man7/cdist.text index a4c88c1d..9f7dbbab 100644 --- a/doc/man/man7/cdist.text +++ b/doc/man/man7/cdist.text @@ -34,7 +34,7 @@ pull mechanism (client requests configuration). SEE ALSO -------- -- Website: http://www.nico.schottelius.org/cdist/[] +- Website: http://www.nico.schottelius.org/software/cdist/[] - cdist-best-practise(7) - cdist-deploy-to(1) - cdist-hacker(7) From ca84f1b2b8a402812ca6664ab88fa7bf4e51b2f2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 2 Jun 2011 08:14:50 +0200 Subject: [PATCH 02/10] more requirements for code submission Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-hacker.text | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/man/man7/cdist-hacker.text b/doc/man/man7/cdist-hacker.text index 027f28aa..efd6ef7d 100644 --- a/doc/man/man7/cdist-hacker.text +++ b/doc/man/man7/cdist-hacker.text @@ -54,6 +54,7 @@ everybody using cdist, you're welcome to propose inclusion into upstream. There are though some requirements to ensure your changes don't break others work nor kill the authors brain: +- All files should contain the usual header (Author, Copying, etc.) - Code submission must be done via git - Do not add conf/manifest/init - This file should only be touched in your private branch! From 56cf428d4c4c234196ed5a27a7a1005184b594eb Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 8 Jun 2011 21:19:05 +0200 Subject: [PATCH 03/10] use kill 0 on SIGINT and SIGTERM, but not on trap EXIT Signed-off-by: Nico Schottelius --- bin/cdist-config | 10 ++++++---- bin/cdist-mass-deploy | 13 ------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 363f95fb..5bbeed6e 100644 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -355,15 +355,17 @@ __cdist_tmp_removal() rm -rf "${__cdist_tmp_dir}" } -__cdist_exit_on_kill() +__cdist_kill_on_interrupt() { - # FIXME: before 1.8.0 -> kill all children, but do not segfault - # kill 0 __cdist_tmp_removal + kill 0 } +# Remove tempfiles at normal exit trap __cdist_tmp_removal EXIT -trap __cdist_exit_on_kill INT TERM + +# Kill children on interrupt +trap __cdist_kill_on_interrupt INT TERM ################################################################################ diff --git a/bin/cdist-mass-deploy b/bin/cdist-mass-deploy index 96427f7a..b562d0f8 100755 --- a/bin/cdist-mass-deploy +++ b/bin/cdist-mass-deploy @@ -25,19 +25,6 @@ [ $# -ge 1 ] || __cdist_usage "[-p] [target host ]" set -u -# trap __cdist_tmp_removal EXIT -trap killandclean EXIT - -killandclean() -{ - __cdist_echo info "Existing and killing children..." - kill 0 - - # Ensure tmp stuff is being removed - __cdist_cleanly_exit -} - - filter() { awk -v host=$1 '{ print "[" host "] " $0 }' From 6f99de75a59e54523656dd3e42109ea54121191e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 8 Jun 2011 21:23:53 +0200 Subject: [PATCH 04/10] only trap signals in front end scripts Otherwise children execute kill egain and the shell segfaults Signed-off-by: Nico Schottelius --- bin/cdist-config | 5 ++--- bin/cdist-deploy-to | 3 +++ bin/cdist-mass-deploy | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 5bbeed6e..31c7afce 100644 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -355,6 +355,8 @@ __cdist_tmp_removal() rm -rf "${__cdist_tmp_dir}" } +# Does not work in children, will be called again in every script! +# Use only in interactive "front end" scripts __cdist_kill_on_interrupt() { __cdist_tmp_removal @@ -364,9 +366,6 @@ __cdist_kill_on_interrupt() # Remove tempfiles at normal exit trap __cdist_tmp_removal EXIT -# Kill children on interrupt -trap __cdist_kill_on_interrupt INT TERM - ################################################################################ # Type diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 138248d6..bf5614bc 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -25,6 +25,9 @@ [ $# -eq 1 ] || __cdist_usage "" set -eu +# Kill children on interrupt - only in interactive scripts +trap __cdist_kill_on_interrupt INT TERM + __cdist_target_host="$1" # Make target host available for non-core diff --git a/bin/cdist-mass-deploy b/bin/cdist-mass-deploy index b562d0f8..5ebfa1c2 100755 --- a/bin/cdist-mass-deploy +++ b/bin/cdist-mass-deploy @@ -25,6 +25,9 @@ [ $# -ge 1 ] || __cdist_usage "[-p] [target host ]" set -u +# Kill children on interrupt - only in interactive scripts +trap __cdist_kill_on_interrupt INT TERM + filter() { awk -v host=$1 '{ print "[" host "] " $0 }' From d4eff6f89bdb13a45f11045dd1ef45d721a8518b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 8 Jun 2011 21:25:52 +0200 Subject: [PATCH 05/10] ++todo Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 871045f2..d626493d 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -37,6 +37,9 @@ CORE -> add function to cdist-config, import from cdist-cache - check all all internal variables are prefixed with __cdist +- Define / document "this is what should be on host X" + and have it parsable by different (shinken) tool + -> given after manifest run already! TYPES ------ From d7ae5c88e61f9e7cb12015019c3ccd7c3899b047 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 8 Jun 2011 21:26:13 +0200 Subject: [PATCH 06/10] and EXIT! Signed-off-by: Nico Schottelius --- bin/cdist-config | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/cdist-config b/bin/cdist-config index 31c7afce..f7fb5ac0 100644 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -361,6 +361,7 @@ __cdist_kill_on_interrupt() { __cdist_tmp_removal kill 0 + exit 1 } # Remove tempfiles at normal exit From 84d2930691715c1c16ae0d2c21a2cb5733a28381 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 8 Jun 2011 23:24:09 +0200 Subject: [PATCH 07/10] typo fixes (thanks to Derek Brost) Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-type.text | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/man/man7/cdist-type.text b/doc/man/man7/cdist-type.text index 8d1b9ae4..1af386fb 100644 --- a/doc/man/man7/cdist-type.text +++ b/doc/man/man7/cdist-type.text @@ -183,12 +183,12 @@ level tools like ruby installed. If a type requires specific tools to be present on the target, there must be another type that provides this tool and the first type should create an object of the specific type. -If your type wants to save temporay data, that may be used by other types +If your type wants to save temporary data, that may be used by other types later on (for instance __file), you can save them in the subdirectory "files" below $__object (but you must create it yourself). cdist will not touch this directory. -If your type contains static files, it's also recommened to place them in +If your type contains static files, it's also recommended to place them in a folder named "files" within the type (again, because cdist guarantees to never ever touch this folder). From 80c1d7d0ccfe71888f7899d80f019db51ae1b4d8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 13 Jun 2011 18:35:42 +0200 Subject: [PATCH 08/10] idea of installing an os via cdist Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-06-13.installation-via-cdist | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doc/dev/logs/2011-06-13.installation-via-cdist diff --git a/doc/dev/logs/2011-06-13.installation-via-cdist b/doc/dev/logs/2011-06-13.installation-via-cdist new file mode 100644 index 00000000..f43a4ba3 --- /dev/null +++ b/doc/dev/logs/2011-06-13.installation-via-cdist @@ -0,0 +1,13 @@ +Provisioning Server ideas + + - bootup kernel on target host via TFTP/PXE + - start our code that + - enables networking (dhcp) + - enables sshd + +Requires: + - Program that creates our blob that needs to be started + - for Linux: initrd + - Including ssh keys -> known! + - startup sshd + From 167098d731dcdc19be3aaeaee86cc320f982ba8b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Jun 2011 00:00:51 +0200 Subject: [PATCH 09/10] more ideas on how to install via cdist Signed-off-by: Nico Schottelius --- .../logs/2011-06-13.installation-via-cdist | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/doc/dev/logs/2011-06-13.installation-via-cdist b/doc/dev/logs/2011-06-13.installation-via-cdist index f43a4ba3..1b7e6c97 100644 --- a/doc/dev/logs/2011-06-13.installation-via-cdist +++ b/doc/dev/logs/2011-06-13.installation-via-cdist @@ -11,3 +11,102 @@ Requires: - Including ssh keys -> known! - startup sshd +-------------------------------------------------------------------------------- +Setup for installation server: + + - have dhcpd available + - install tftpd server + - configure dhcp to tell clients to boot from tftp server + - have a kernel + +-------------------------------------------------------------------------------- +Ideas on how to create "blob" + + - Use tools from system? + -> requires same arch on destination! + - Use debian|...| base? + -> works with cuni! +-------------------------------------------------------------------------------- +tftp via cuni: +debian pxelinux.0 pxelinux.cfg + +[19:44] kr:tftp% ln -s /usr/lib/syslinux/ + +-------------------------------------------------------------------------------- +How to create the initrd? + Base from ... + arch? + debian? + +- needs many hardware support / in kernel? + - fit to kernel? + +-------------------------------------------------------------------------------- +Based on Debian +[21:33] kr:tftp% sudo debootstrap --arch=i386 squeeze debian-squeeze + +sudo chroot debian-squeeze /bin/bash + apt-get install openssh-server + + +-------------------------------------------------------------------------------- +Based on Archlinux + +Edit / create pacman.conf +Server = ftp://mirrors.kernel.org/archlinux/$repo/os/i686 + +[21:40] kr:~% grep -v ^# pacman.conf | grep -v '^$' +[options] +HoldPkg = pacman glibc +SyncFirst = pacman +Architecture = auto +[core] +Include = Server = ftp://mirrors.kernel.org/archlinux/$repo/os/i686 +[extra] +Include = Server = ftp://mirrors.kernel.org/archlinux/$repo/os/i686 +[community] +Include = Server = ftp://mirrors.kernel.org/archlinux/$repo/os/i686 +[archlinuxfr] +Server = http://repo.archlinux.fr/$arch + +[21:40] kr:tftp% sudo mkarchroot -C ~/pacman.conf archlinuxroot + +[21:42] kr:tftp% sudo mkarchroot -C ~/pacman.conf archlinuxroot base + +-------------------------------------------------------------------------------- +Initramfs general: + + - need /init + +Test in Debian: + root@kr:/# ln -s /sbin/init init + +Create initramfs: + [22:47] kr:debian-squeeze% sudo find . -print0 | sudo cpio --null -ov --format=newc | gzip -9 > ../pre-os/initrd.gz + + + +-------------------------------------------------------------------------------- +Gentoo: http://en.gentoo-wiki.com/wiki/Initramfs + +It is possible to specify multiple initramfs to be extracted during boot. This can be useful if you want to create a generic initramfs (for example one that does mdadm) and then add modifications in separate files (for example a custom /etc/mdadm.conf for every machine). + +http://syslinux.zytor.com/wiki/index.php/SYSLINUX#INITRD_initrd_file + It supports multiple filenames separated by commas. This is mostly useful for initramfs, which can be composed of multiple separate cpio or cpio.gz archives. Note: all files except the last one are zero-padded to a 4K page boundary. This should not affect initramfs. +-------------------------------------------------------------------------------- +Multiple initrds, #1: + +LABEL preos + MENU LABEL Pre OS (Debian Squeeze) + KERNEL debian-squeeze/boot/vmlinuz-2.6.32-5-686 + INITRD debian-squeeze/boot/initrd.img-2.6.32-5-686,pre-os/initrd.gz + +-------------------------------------------------------------------------------- +Debug in rootfs: +root@kr:/# passwd +Enter new UNIX password: +Retype new UNIX password: +passwd: password updated successfully +test +-------------------------------------------------------------------------------- +Multiple nics in Debian... From f2badcd2b7ff3b1179b2da9660a3329a903377fd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 Jun 2011 00:03:38 +0200 Subject: [PATCH 10/10] in theory can export library to user now Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-06-14.library_for_user | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/dev/logs/2011-06-14.library_for_user diff --git a/doc/dev/logs/2011-06-14.library_for_user b/doc/dev/logs/2011-06-14.library_for_user new file mode 100644 index 00000000..325150e2 --- /dev/null +++ b/doc/dev/logs/2011-06-14.library_for_user @@ -0,0 +1,19 @@ +How to make library functions available to manifest, explorer, etc. + +Some ideas / background: + + - do not have the user to source $__lib/foo if not needed + - have $__cdist_lib for internal stuff (probably referring to core/) + +Implementation: + +load_lib() +{ + . $__cdist_lib/* +} + +run_code_from_user() +{ + load_lib + . file_from_user +}