On Thu, 09 Jun 2011 14:19:21 +0200 Sjoerd Oostdijck <sjoer...@ripe.net> wrote: 

SO> On 6/9/11 2:05 PM, no-re...@cfengine.com wrote:
SO> The end goal is, for example, installing a large list of packages. The
SO> the promise that installs the package then sets a certain class which
SO> contains the package name.
SO> (something like:   promise_repaired => {"installed_$(this.promiser)"}  )

SO> After that I would like to know what servers needed what software
SO> installed, so I'd like reporting on what was done. Instead of blindly
SO> listing all possible classes in the reports section I would like to wild
SO> card this somehow *and* output what specific class it matched so that I
SO> know what happened.

SO> something like:
SO>  reports:
SO>     installed_(.*):: # put the .* in $1
SO>         "$1 was installed"; # $1 would interpolate to "somerpm"

I would parameterize a bundle with the package name, e.g.

body classes context_sensitive(x)
# Define a class from a prefix x concatenated with the outcome of the promise
{
  promise_repaired => { "$(x)_repaired" };
  promise_kept     => { "$(x)_kept"     };
  repair_failed    => { "$(x)_failed"   };
  repair_denied    => { "$(x)_denied"   };
  repair_timeout   => { "$(x)_timeout"  };
}

bundle agent my_package_add_or_delete(service, pkg)
{
# just an example using Redhat
  redhat::
    "$(pkg)"
    package_policy => "add",
    package_method => yum_rpm,
    classes        => context_sensitive("$(service)_package_add");

reports:
  "bundle_my_package_add_or_delete: The package for service $(service) was 
installed by cfengine"
  ifvarclass => "$(service)_package_add_repaired";
}

I hope that's what you were looking for...

Ted
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to