[rudder-dev] Best Practises for writing techniques
Michael Gliwinski
Michael.Gliwinski at henderson-group.com
Fri Mar 1 12:10:07 CET 2013
Thanks for your answer, before I start thinking about the rest, just a
question about variables. Just whenever you have time, just trying to
understand what's going on :)
On Thursday 28 Feb 2013 18:31:24 Nicolas Charles wrote:
> > 3c. initial tests show it should be OK, but do you think there could be
> > problems using those variables from other (e.g. associated) techniques?
>
> Unfortunately, yes, there could.
> We have no way do define the order in which the bundles will be
> executed, so there is no guarantee that the variable will already be
> defined when calling it from another technique (unless you define some
> variables in the bundle common)
Would that be something different between how Rudder drives CFEngine and plain
CFEngine?
I wrote a couple of tests yesterday and based my assumptions on that. This
appears to work, i.e. when running `cf-agent -f ./cf-test-var-deps.cf -KI` I
get:
R: [master/master_config] mnt.technique_name = 'mnt'
R: [master/master_config] mnt_config.point[1] = '/tmp/mntbar'
R: [master/master_config] mnt_config.point[0] = '/tmp/mntfoo'
R: [master/master] master_config.foo = 'master'
R: [mnt/mnt_config] master_config.foo_file = '/tmp/foo'
R: [mnt/mnt_config] master_config.bar_file = '/tmp/bar'
**********************************************************************************************
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to the email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
When addressed to our clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing client engagement leter or contract.
If you have received this email in error please notify support at henderson-group.com
John Henderson (Holdings) Ltd
Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland, BT36 4RT.
Registered in Northern Ireland
Registration Number NI010588
Vat No.: 814 6399 12
*********************************************************************************
-------------- next part --------------
bundle agent master_config (technique_name)
{
vars:
any::
"foo" string => "${technique_name}";
"foo_file" string => "/tmp/foo";
"bar_file" string => "/tmp/bar";
"point_idx" slist => getindices("mnt_config.point");
reports:
a|!a::
"[${technique_name}/master_config] mnt.technique_name = '${mnt.technique_name}'";
"[${technique_name}/master_config] mnt_config.point[${point_idx}] = '${mnt_config.point[$(point_idx)]}'";
}
-------------- next part --------------
bundle agent master {
vars:
any::
"technique_name" string => "master";
methods:
any::
"master_config($technique_name)" usebundle => master_config("${technique_name}");
reports:
a|!a::
"[${technique_name}/master] master_config.foo = '${master_config.foo}'";
}
-------------- next part --------------
bundle agent mnt
{
vars:
any::
"technique_name" string => "mnt";
methods:
any::
"mnt_config(${technique_name})" usebundle => mnt_config("${technique_name}");
}
-------------- next part --------------
bundle agent mnt_config (technique_name) {
vars:
any::
"point[0]" string => "/tmp/mntfoo";
"point[1]" string => "/tmp/mntbar";
reports:
a|!a::
"[${technique_name}/mnt_config] master_config.foo_file = '${master_config.foo_file}'";
"[${technique_name}/mnt_config] master_config.bar_file = '${master_config.bar_file}'";
}
-------------- next part --------------
# test if you can reference variables in parametrised bundles and
# if two bundles can reference each other's variables (like a circular dep)
# ans: both yes (whether defined in the same file or not)
body common control {
inputs => { "cf-test-var-deps-master.cf", "cf-test-var-deps-master-config.cf", "cf-test-var-deps-mnt.cf", "cf-test-var-deps-mnt-config.cf" };
bundlesequence => { "master", "mnt" };
}
More information about the rudder-dev
mailing list