Forum: Cfengine Help
Subject: Re: is it possible to combine arrays and lists?
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,16807,16823#msg-16823
Seva Gluschenko Wrote:
> As you can see, string lists and arrays aren't
> expanded at all. I thought professionals don't
> give advices they never tried.
I don't have to give you advice at all if you prefer. I did however say expand
scalars not lists or arrays. For example:
# cf-agent -IKf ./temp.cf
-> Saving edit changes to file /tmp/temp.conf
Edited file /tmp/temp.conf
# cat /tmp/temp.conf
vrrp_instance ID2 {
state BACKUP
interface eth1
virtual_router_id 112
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass some_pass
}
virtual_ipaddress {
172.16.0.12 label eth1:12
172.16.0.112 label eth1:112
}
notify_backup "/usr/local/bin/vrrp.sh BACKUP ID2"
notify_master "/usr/local/bin/vrrp.sh MASTER ID2"
notify_fault "/usr/local/bin/vrrp.sh FAULT ID2"
}
# cat temp.cf
######################
body common control {
bundlesequence => { "neil" };
inputs => { "cfengine_stdlib.cf" };
}
bundle agent neil{
vars:
"id" string => "ID2";
"int" string => "eth1";
"vrid" string => "virtual_router_id 112";
"vips" string => "
172.16.0.12 label eth1:12
172.16.0.112 label eth1:112
";
"notify" string => "
notify_backup \"/usr/local/bin/vrrp.sh BACKUP ID2\"
notify_master \"/usr/local/bin/vrrp.sh MASTER ID2\"
notify_fault \"/usr/local/bin/vrrp.sh FAULT ID2\"
";
files:
"/tmp/temp.conf"
create => "true",
edit_defaults => empty,
edit_line => expandme("/root/inputs/temp.conf");
}
bundle edit_line expandme(tmp){
insert_lines:
"${tmp}"
insert_type => "file",
expand_scalars => "true";
}
# cat temp.conf
vrrp_instance ${neil.id} {
state BACKUP
interface ${neil.int}
${neil.vrid}
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass some_pass
}
virtual_ipaddress {
${neil.vips}
}
${neil.notify}
}
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine