2011-06-21 10:34:18 +00:00
|
|
|
Steven, Nico:
|
|
|
|
|
|
|
|
Problem:
|
|
|
|
How to execute a function instead of binary
|
|
|
|
|
|
|
|
Solutions:
|
|
|
|
|
|
|
|
1)
|
|
|
|
(
|
|
|
|
cat $lib/*
|
|
|
|
cat bin/cdist-config
|
|
|
|
echo $function $args
|
|
|
|
) | ssh foo
|
|
|
|
|
2011-06-23 10:13:46 +00:00
|
|
|
Works partly, does not work for export = ...
|
|
|
|
Needs to copy over lib every time again!
|
|
|
|
|
2011-06-21 10:34:18 +00:00
|
|
|
2)
|
|
|
|
scp $dir/lib.sh root@foo:/tmp/lib.sh
|
|
|
|
cat << DONE | ssh root@foo sh
|
|
|
|
source /tmp/lib.sh
|
2011-06-23 10:13:46 +00:00
|
|
|
export foo=bla
|
|
|
|
function args
|
2011-06-21 10:34:18 +00:00
|
|
|
DONE
|
|
|
|
|
2011-06-23 10:13:46 +00:00
|
|
|
Caches lib directory
|
|
|
|
|
2011-06-21 10:34:18 +00:00
|
|
|
3) follow up to 1)
|
|
|
|
__run_remote()
|
|
|
|
{
|
|
|
|
cat << eof | ssh foo
|
|
|
|
|
|
|
|
. /cdist-config
|
|
|
|
"$@" # NOT USABLE, no export = export = lines possible!
|
|
|
|
|
|
|
|
eof
|
|
|
|
|
2011-06-23 10:13:46 +00:00
|
|
|
4) final solution
|
|
|
|
- write for every remote job a new function
|
|
|
|
- this functions prepares env + reuses ssh header
|
|
|
|
|
|
|
|
__cdist_remote_explorer()
|
|
|
|
{
|
|
|
|
cat << eof
|
|
|
|
$__cdist_remote_header
|
|
|
|
export foo1=bar
|
|
|
|
export foo2=bar
|
|
|
|
export foo3=bar
|
|
|
|
|
|
|
|
"$@"
|
|
|
|
eof | __cdist_ssh
|
|
|
|
}
|
|
|
|
|
2011-06-21 10:34:18 +00:00
|
|
|
|
|
|
|
Problems found and solved:
|
|
|
|
|
|
|
|
- remote shell cannot work due to multi line variable export
|
|
|
|
- caching library directory with scp
|
|
|
|
- create function for every remote action
|
|
|
|
-> prepares environment
|
|
|
|
|