Org Babel functions for CFEngine 3
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.org
ob-cfengine3.el

README.org

Org Babel functions for CFEngine 3

Table of contents

Usage

Respect promise locks

The --no-locks argument is passed by default. To use locks set the header argument use-locks to yes.

#+BEGIN_SRC cfengine3 :use-locks yes
  bundle agent main
  {
    reports:

      "My Content";
  }
#+END_SRC

Don’t automatically include the stdlib

The standard library is included by default via body file control. To avoid this define set include-stdlib to no for example:

#+BEGIN_SRC cfengine3 :include-stdlib no
  bundle agent main
  {
    reports:

      "My Content"
        printfile => cat($(this.promise_filename));
  }
#+END_SRC

#+RESULTS:
#+begin_example
  /home/nickanderson/org/cfengine3-15841vLB:6:0: error: Undefined body cat with type printfile
     error: Policy failed validation with command '"/home/nickanderson/.cfagent/bin/cf-promises" -c "/home/nickanderson/org/cfengine3-15841vLB"'
     error: CFEngine was not able to get confirmation of promises from cf-promises, so going to failsafe
     error: CFEngine failsafe.cf: /home/nickanderson/.cfagent/inputs /home/nickanderson/.cfagent/inputs/failsafe.cf
     error: No suitable server found
     error: No suitable server found
  R: Built-in failsafe policy triggered
    notice: Q: ".../cf-agent" -f /":    error: No suitable server found
  Q: ".../cf-agent" -f /":    error: No suitable server found
  Q: ".../cf-agent" -f /":    error: No suitable server found
#+end_example

Specify the bundlesequence

You can specify the bundlesequence by setting the bundlesequence header. For example:

#+BEGIN_SRC cfengine3 :bundlesequence one,two
  bundle agent one
  {
    reports:
      "Running bundle $(this.bundle)";
  }
  bundle agent two
  {

    reports:
      "Running bundle $(this.bundle)";
  }
#+END_SRC

#+RESULTS:
: R: Running bundle one
: R: Running bundle two

Define additional classes

You can define additional classes by setting the define header.

#+BEGIN_SRC cfengine3 :define EXTRA,MORE
  bundle agent main
  {
    reports:
      EXTRA::
       "EXTRA Class defined";
      MORE::
        "EVEN MORE";
  }
#+END_SRC

#+RESULTS:
: R: EXTRA Class defined
: R: EVEN MORE

Change the output log level

By default the agent if silent about repairs and only emits output on promises that are not kept and promises that explicitly output information (like a reports type promise).

Run with inform level output

#+BEGIN_SRC cfengine3 :info yes
  bundle agent main
  {
    commands:
      "/bin/true";
  }
#+END_SRC
#+RESULTS:
  :     info: Executing 'no timeout' ... '/bin/true'
  :     info: Completed execution of '/bin/true'

Run with verbose level output

#+BEGIN_SRC cfengine3 :verbose yes
  bundle agent main
  {
    commands:
      "/bin/true";
  }
#+END_SRC
#+RESULTS:
#+begin_example
   verbose: Could not open extension plugin 'cfengine-enterprise.so' from '/home/nickanderson/.cfagent/lib/cfengine-enterprise.so': (not installed)
   verbose: Successfully opened extension plugin 'cfengine-enterprise.so' from '/var/cfengine/lib/cfengine-enterprise.so'
   verbose: Successfully loaded extension plugin 'cfengine-enterprise.so'
   verbose:  CFEngine Core 3.11.0
   verbose: ----------------------------------------------------------------
   verbose:  Initialization preamble 
   verbose: ----------------------------------------------------------------
  ... snipped for brevity
   verbose: No lock purging scheduled
   verbose: Outcome of version (not specified) (agent-0): Promises observed - Total promise compliance: 86% kept, 14% repaired, 0% not kept (out of 7 events). User promise compliance: 86% kept, 14% repaired, 0% not kept (out of 7 events). CFEngine system compliance: 0% kept, 0% repaired, 0% not kept (out of 0 events).
#+end_example

Run with debug level output

#+BEGIN_SRC cfengine3 :debug yes
  bundle agent main
  {
    commands:
      "/bin/true";
  }
#+END_SRC
#+RESULTS:
#+begin_example
   debug: Trying to shlib_open extension plugin 'cfengine-enterprise.so' from '/home/nickanderson/.cfagent/lib/cfengine-enterprise.so'
   debug: Could not open shared library: No such file or directory
 verbose: Could not open extension plugin 'cfengine-enterprise.so' from '/home/nickanderson/.cfagent/lib/cfengine-enterprise.so': (not installed)
   debug: Trying to shlib_open extension plugin 'cfengine-enterprise.so' from '/var/cfengine/lib/cfengine-enterprise.so'
 verbose: Successfully opened extension plugin 'cfengine-enterprise.so' from '/var/cfengine/lib/cfengine-enterprise.so'
 verbose: Successfully loaded extension plugin 'cfengine-enterprise.so'
   debug: Setting hard class: default:debug_mode
   debug: Setting hard class: default:opt_debug
   debug: Setting hard class: default:verbose_mode
   debug: Setting hard class: default:inform_mode
 verbose:  CFEngine Core 3.11.0
 verbose: ----------------------------------------------------------------
 verbose:  Initialization preamble 
 verbose: ----------------------------------------------------------------
... snipped for brevity
 verbose: No lock purging scheduled
   debug: Entering lock operation in 'FindLockTime()': lock_id = 'CF_CRITICAL_SECTION', lock_checksum = 'CF_CRITICAL_SECTION', lock.pid = '0', lock.time = '0', lock.process_start_time = '0'
   debug: Exiting lock operation in 'FindLockTime()': lock_id = 'CF_CRITICAL_SECTION', lock_checksum = 'CF_CRITICAL_SECTION', lock.pid = '0', lock.time = '0', lock.process_start_time = '0'
   debug: Entering lock operation in 'WriteLockData()': lock_id = 'CF_CRITICAL_SECTION', lock_checksum = 'CF_CRITICAL_SECTION', lock.pid = '30808', lock.time = '1514915506', lock.process_start_time = '1026478'
   debug: Exiting lock operation in 'WriteLockData()': lock_id = 'CF_CRITICAL_SECTION', lock_checksum = 'CF_CRITICAL_SECTION', lock.pid = '30808', lock.time = '1514915506', lock.process_start_time = '1026478'
   debug: Entering lock operation in 'RemoveLock()'. lock_id = 'CF_CRITICAL_SECTION', lock_checksum = 'CF_CRITICAL_SECTION'
   debug: Exiting lock operation in 'RemoveLock()'. lock_id = 'CF_CRITICAL_SECTION', lock_checksum = 'CF_CRITICAL_SECTION'
   debug: VariableTableGet(default:control_common.version): NOT FOUND
 verbose: Outcome of version (not specified) (agent-0): Promises observed - Total promise compliance: 86% kept, 14% repaired, 0% not kept (out of 7 events). User promise compliance: 86% kept, 14% repaired, 0% not kept (out of 7 events). CFEngine system compliance: 0% kept, 0% repaired, 0% not kept (out of 0 events).
#+end_example

Installation

From source

Clone the repo, add it to your load path

(add-to-list 'load-path "~/src/ob-cfengine3/")
(require 'ob-cfengine3)

Using package

(ob-cfengine3 :repo "nickanderson/ob-cfengine3" :fetcher github)