Seva- What you probably want to do is package everything into a method. So, something like this (I haven't checked it for syntax, I am just typing to give you an idea). Note that you'll be saving space sometimes and wasting sometimes depending on how many times you need to re-do a task, so my example is the same size as yours, but consolidates and abstracts the information into a "subroutine".
-Dan bundle agent domap(thing) { vars: "conf_path" string => "/etc/mail"; files: "$(conf_path)/$(thing)" copy_from => my_scp("$(g.conf_path)/$(thing)"), classes => if_repaired("$(thing)_updated"), perms => mog("0400","mail","root"), comment => "Set up mail server $(thing) configuration item"; commands: "/usr/bin/makemap hash < $(conf_path)/$(thing) > $(conf_path)/$(thing).db" useshell => "true", comment => "Rebuild $(thing) database", ifvarclass => canonify("$(thing)_updated"); } bundle agent mailmaps { vars: "db_cfg" slist => { "access", "virtuser" }; methods: "any" usebundle => domap($db_cfg); } > Hello guys, > > I'm new to this list and new to the cfengine either. Working out ways > to deploy the community version, I'm getting stuck with limitations > sourced by "classes not variables" paradigm. For example, currently I > have such a case for a mailserver controls: > > bundle agent mailmaps > { > vars: > "conf_path" string => "/etc/mail"; > "db_cfg" slist => { "access", "virtuser" }; > > files: > "$(conf_path)/$(db_cfg)" > copy_from => my_scp("$(g.conf_path)/$(db_cfg)"), > classes => if_repaired("$(db_cfg)_updated"), > perms => mog("0400","mail","root"), > comment => "Set up mail server configuration item"; > > commands: > access_updated:: > "/usr/bin/makemap hash < $(conf_path)/access > $(conf_path)/access.db > " > useshell => "true", > comment => "Rebuild access database"; > > virtuser_updated:: > "/usr/bin/makemap hash < $(conf_path)/virtuser > > $(conf_path)/virtuser.db" > useshell => "true", > comment => "Rebuild virtuser database"; > } > > Is there any good method to eliminate repeated patterns in commands > section and use some template or iteration? > > -- > SY, Seva Gluschenko > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine