Forum: CFEngine Help
Subject: insert line: bug ??
Author: stchesmeli
Link to topic: https://cfengine.com/forum/read.php?3,24539,24539#msg-24539
Hello all,
i'm wondering if there is a bug in insert line.... let me explain
I'm trying to build my dhcpd.conf with list of host and array of macs and ips.
My code:
bundle common icebox_lan
{
vars:
"my_macs" string => "50:e5:49:5b:e2:be";
"my_macs" string => "00:1e:8f:79:ac:e9";
"my_macs" string => "a8:e3:ee:02:dc:58";
"my_macs" string => "7c:61:93:8d:93:b8";
"my_macs" string => "00:19:1d:fd:55:b0";
"my_macs" string => "00:24:d6:87:18:80";
"my_macs" string => "00:26:b9:d2:ce:aa";
"my_macs" string => "4c:0f:6e:d4:c2:29";
"my_macs" string => "e8:5b:5b:c1:17:86";
"my_macs" string => "00:26:4d:a5:d3:68";
"my_macs" string => "00:27:0e:07:61:a0";
"my_macs" string => "e8:be:81:2c:27:59";
"my_ips" string => "192.168.50.10";
"my_ips" string => "192.168.50.40";
"my_ips" string => "192.168.50.18";
"my_ips" string => "192.168.50.19";
"my_ips" string => "192.168.50.25";
"my_ips" string => "192.168.50.50";
"my_ips" string => "192.168.50.51";
"my_ips" string => "192.168.50.20";
"my_ips" string => "192.168.50.30";
"my_ips" string => "192.168.50.31";
"my_ips" string => "192.168.50.254";
"my_ips" string => "192.168.50.1";
"my_hosts" slist => getindices("my_macs");
"my_domain" string => "icebox.lan";
"my_router" string => "$(my_ips)";
"my_ns1" string => "$(my_ips)";
"my_ns2" string => "$(my_ips)";
}
bundle common goldorak_conf
{
vars:
"pkg_dhcpd" string => "isc-dhcp-server";
}
bundle agent set_goldo_dhcp_server
{
vars:
"my_dhcdp_options" string =>
"ddns-update-style none;
log-facility local7;
";
"my_share_network" string =>
"shared-network home
{
subnet 192.168.50.0 netmask 255.255.255.0 {
option domain-name \"$(icebox_lan.my_domain)\";
option domain-name-servers $(icebox_lan.my_ns1), $(icebox_lan.my_ns2);
option routers $(icebox_lan.my_router);
default-lease-time 600;
max-lease-time 7200;
}
subnet 10.0.0.0 netmask 255.255.255.0 {
option domain-name \"blackhole.lan\";
option domain-name-servers 10.0.0.1;
option routers 10.0.0.1;
range 10.0.0.10 10.0.0.250;
default-lease-time 600;
max-lease-time 7200;
}
}
";
packages:
"$(goldorak_conf.pkg_dhcpd)"
package_policy => "add",
package_method => generic,
classes => if_repaired("dhcpd_installed");
files:
"/etc/dhcp/dhcpd.conf"
comment => "Set the dhcpd configuration",
edit_line => dhcpdconf(${my_dhcdp_options}, ${my_share_network},
@(icebox_lan.my_hosts), "icebox_lan.my_macs", "icebox_lan.my_ips" ),
create => "true",
edit_defaults => empty,
perms => mog("644","root","root"),
classes => if_repaired("dhcpd_repaired");
processes:
"/usr/sbin/dhcpd"
restart_class => "restart_dhcpd";
commands:
dhcpd_installed::
"/usr/sbin/update-rc.d $(goldorak_conf.pkg_dhcpd) defaults";
dhcpd_repaired|restart_dhcpd::
"/etc/init.d/isc-dhcp-server restart";
}
bundle edit_line dhcpdconf(doptions,dnetwork,dhosts, dmacs, dips)
{
insert_lines:
"$(doptions)
$(dnetwork)";
"host $(dhosts) { $(const.n) $(const.t) hardware ethernet
$($(dmacs)[$(dhosts)]); $(const.n) $(const.t) fixed-address
$($(dips)$(dhosts)]); $(const.n) }";
}
my output dhcpd.conf generated:
ddns-update-style none;
log-facility local7;
shared-network home
{
subnet 192.168.50.0 netmask 255.255.255.0 {
option domain-name "icebox.lan";
option domain-name-servers 192.168.50.254, 192.168.50.1;
option routers 192.168.50.254;
default-lease-time 600;
max-lease-time 7200;
}
subnet 10.0.0.0 netmask 255.255.255.0 {
option domain-name "blackhole.lan";
option domain-name-servers 10.0.0.1;
option routers 10.0.0.1;
range 10.0.0.10 10.0.0.250;
default-lease-time 600;
max-lease-time 7200;
}
}
host lg-wifi {
hardware ethernet 00:26:4d:a5:d3:68;
fixed-address 192.168.50.31;
}
host livebox {
hardware ethernet e8:be:81:2c:27:59;
fixed-address 192.168.50.1;
host vaio {
hardware ethernet 4c:0f:6e:d4:c2:29;
fixed-address 192.168.50.20;
host goldorak {
hardware ethernet 00:27:0e:07:61:a0;
fixed-address 192.168.50.254;
host ps3 {
hardware ethernet a8:e3:ee:02:dc:58;
fixed-address 192.168.50.18;
host wii {
hardware ethernet 00:19:1d:fd:55:b0;
fixed-address 192.168.50.25;
host dell {
hardware ethernet 00:24:d6:87:18:80;
fixed-address 192.168.50.50;
host mp620 {
hardware ethernet 00:1e:8f:79:ac:e9;
fixed-address 192.168.50.40;
host dell-eth {
hardware ethernet 00:26:b9:d2:ce:aa;
fixed-address 192.168.50.51;
host aziz {
hardware ethernet 50:e5:49:5b:e2:be;
fixed-address 192.168.50.10;
host htc {
hardware ethernet 7c:61:93:8d:93:b8;
fixed-address 192.168.50.19;
host lg {
hardware ethernet e8:5b:5b:c1:17:86;
fixed-address 192.168.50.30;
As you see, the first host entry is ok:
host lg-wifi {
hardware ethernet 00:26:4d:a5:d3:68;
fixed-address 192.168.50.31;
}
But the next not:
host livebox {
hardware ethernet e8:be:81:2c:27:59;
fixed-address 192.168.50.1;
missing the last line with " }". I don't understand why...
And when i change the insert line, insert space for example, or changing
$(const.n) or $(const.t) with the real "enter" or "tab" sometime the line is ok
!! ...
My cfengine version: 3.2.1
Official package for ubuntu 11.10 from cfengine website.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine