Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neilhwatson/e1ee04fc3ad49cc61b8d to your computer and use it in GitHub Desktop.
Save neilhwatson/e1ee04fc3ad49cc61b8d to your computer and use it in GitHub Desktop.
INSTALL.md

Installation

  1. Copy the contents of masterfiles into your masterfiles or equivalent repository.
  2. Include all EFL .cf files in your inputs list in the common control body. Example:
bundle common efl_lib
{
   vars:
      cfengine_3_6::
         'lib_dir' string => 'lib/3.6/EFL';
         'inputs'   slist => {
            '${lib_dir}/efl_common.cf',
            '${lib_dir}/efl_update.cf',
            '${lib_dir}/evolve_freelib.cf'
         };
}

body common control
{
   inputs => {
      ....
      '@{efl_lib.inputs}',
      ....
   };
}

Next, build your data files to feed the bundles. Typically store the data files in masterfiles/efl_data.

Building data files

Here's a trivial example to get you started. First create data file to define class.

vim masterfiles/efl_data/classes/efl_classmatch.json
[
   {
      "class_to_set" : "my_dmz_hosts",
      "regex"        : "ipv4_10_0_[2,3,4]_\d+",
      "promisee"     : "dmz security"
   }
]

Then a command promise.
vim masterfiles/efl_data/bundle_params/efl_command.json
[
   {
      "class" : "my_dmz_hosts",
      "command" : "/usr/local/sbin/encrypt_backup.sh",
      "useshell" : "noshell",
      "module" : "no",
      "ifelapsed" : "1440",
      "promisee" : "dmz security"
   }
]

Call both via the efl_main bundle.
vim mastefiles/efl_data/bundle_params/efl_main.json
[
   {
      "class" : "any"
      "promiser" : "set classes",
      "bundle" : "efl_class_classmatch",
      "ifelapsed" : "1",
      "parameter" : "${sys.inputdir}/efl_data/bundle_params/efl_classmatch.json",
      "promisee" : "cfengine policy"
   },
   {
      "class" : "any",
      "promiser" : "running commands",
      "bundle" : "efl_command",
      "ifelapsed" : "1",
      "parameter" : "${sys.inputdir}/efl_data/bundle_params/efl_command.json",
      "promisee" : "cfengine policy"
   }
]

Elsewhere in your policy call the bundle efl_main with the parameter of the path to efl_main.json. Examples:

body common control
{
   bundlesequence => { .... "efl_main( '${sys.inputdir}/efl_data/bundle_params/efl_main.json' )", ... };
   ...
}

OR

bundle again mymain
{
   methods:
      "EFL" usebundle => efl_main( "${sys.inputdir}/efl_data/bundle_params/efl_main.json" );
      ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment