
body common control
{
      bundlesequence => { "edit_motd" };
}

bundle agent edit_motd
{
  files:
      "/etc/motd"
      edit_line     => my_motd,
      edit_defaults => empty,
      create        => "true";
}

#@ The bundle `my_motd` and body `empty` detail what content we want
#@ in the file using CFEngine's built-in line-editor.

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).";
}

#@ The `my_motd` bundle describes the content we want.

body edit_defaults empty
{
      empty_file_before_editing => "true";
}

#@ Baseline memory model of file to zero/empty before 
#@ populating the model using edit_line my_motd
