Permalink
Browse files

examples from release notes about 3.3.0

  • Loading branch information...
1 parent 37e4303 commit af2516c3f32dcfe92a285286a396dc53378e57e8 @estenberg estenberg committed Apr 6, 2012
Showing with 130 additions and 0 deletions.
  1. +36 −0 examples/motd.cf
  2. +59 −0 examples/service_catalogue.cf
  3. +35 −0 examples/service_catalogue_separate.cf
View
@@ -0,0 +1,36 @@
+
+body common control
+{
+bundlesequence => { "test" };
+}
+
+bundle agent test
+{
+files:
+ "/tmp/motd"
+ edit_line => my_motd,
+ edit_defaults => empty,
+ create => "true";
+}
+
+bundle edit_line my_motd
+{
+vars:
+ "interfaces_str" string => join(", ","sys.interfaces");
+ "ipaddresses_str" string => join(", ","sys.ip_addresses");
+
+insert_lines:
+"Welcome to $(sys.fqhost)!
+This system is managed by CFEngine.
+The policy was last updated on $(sys.last_policy_update).
+The system has $(sys.cpus) cpus.
+Network interfaces on this system are $(interfaces_str),
+and the ip-addresses assigned are $(ipaddresses_str).";
+}
+
+
+
+body edit_defaults empty
+{
+empty_file_before_editing => "true";
+}
@@ -0,0 +1,59 @@
+body common control
+{
+bundlesequence => { "service_catalogue" };
+}
+
+
+bundle agent service_catalogue
+{
+services:
+ "syslog" service_policy => "start";
+ "www" service_policy => "stop";
+}
+
+
+
+bundle agent standard_services(service, state)
+{
+vars:
+
+ debian::
+
+ "startcommand[www]" string => "/etc/init.d/apache2 start";
+ "stopcommand[www]" string => "/etc/init.d/apache2 stop";
+ "processname[www]" string => "apache2";
+
+ "startcommand[syslog]" string => "/etc/init.d/rsyslog start";
+ "stopcommand[syslog]" string => "/etc/init.d/rsyslog stop";
+ "processname[syslog]" string => "rsyslogd";
+
+
+classes:
+
+ "start" expression => strcmp("start","$(state)");
+ "stop" expression => strcmp("stop","$(state)");
+
+processes:
+
+ start::
+
+ ".*$(processname[$(service)]).*"
+
+ comment => "Verify that the service appears in the process table",
+ restart_class => "restart_$(service)";
+
+ stop::
+
+ ".*$(processname[$(service)]).*"
+
+ comment => "Verify that the service does not appear in the process table",
+ process_stop => "$(stopcommand[$(service)])",
+ signals => { "term", "kill"};
+
+ commands:
+
+ "$(startcommand[$(service)])"
+
+ comment => "Execute command to restart the $(service) service",
+ ifvarclass => "restart_$(service)";
+}
@@ -0,0 +1,35 @@
+body common control
+{
+bundlesequence => { "service_catalogue_separate" };
+}
+
+
+bundle agent service_catalogue_separate
+{
+services:
+ "foo" service_policy => "start",
+ service_method => service_bundle_separate;
+
+ "bar" service_policy => "stop",
+ service_method => service_bundle_separate;
+}
+
+body service_method service_bundle_separate
+{
+service_bundle => $(this.promiser)("$(this.service_policy)");
+}
+
+
+bundle agent foo(service_policy)
+{
+reports:
+cfengine_3::
+ "we need to ensure $(service_policy) of foo";
+}
+
+bundle agent bar(service_policy)
+{
+reports:
+cfengine_3::
+ "we need to ensure $(service_policy) of bar";
+}

0 comments on commit af2516c

Please sign in to comment.