SlideShare a Scribd company logo
CFEngine 3

                            Code Freeze 2012
                                      Jan 12, 2012
                                      Brian Repko
       http://www.learnthinkcode.com
Copyright 2011 LearnThinkCode, Inc.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Agenda
●
    Introduction to CFEngine
          ●
              What it is
          ●
              How it works
●
    Examples
●
    New Machine Setup
●
    CFEngine vs Chef vs Puppet




       Copyright 2011 LearnThinkCode, Inc.
       This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
IANAS (sysadmin)
●
    My role has been as a developer / architect
    working with sysadmins to deploy our
    applications
●
    When automated, we have used cfengine
●
    This presentation will use cfengine
    configuration from Entagen (triplemap.com)
    for our examples
●
    Thanks to Frans Lawaetz!


      Copyright 2011 LearnThinkCode, Inc.
      This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
CFEngine
●   Systems Maintenance Tool
       ●   Configures and automates large-scale IT infrastructure
       ●   Ensures the availability, security and compliance of systems and
            applications
●   Created by Mark Burgess (Ph.D in Theoretical Physics)
       ●   CFEngine 1 – released in 1993 (at Oslo University / post-doc)
       ●   CFEngine 2 – released in 1998 (Computer Immunology)
       ●   CFEngine 3 – released in 2008 (Promise Theory)
●   Two editions – Community (FOSS) and Nova (commercial)
       ●   Nova has portal, reporting, native MS Mac/Windows mgmt, high-
            availability, virtualization, KM, commercial support
●   Written in C, runs on all types of systems including mobile, tablet
    and embedded systems
●   Tons of low-level functions and action configurations to reuse
           Copyright 2011 LearnThinkCode, Inc.
           This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Who uses it




   Copyright 2011 LearnThinkCode, Inc.
   This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Components
●   cf-execd
       ●   Cron-like lightweight daemon that runs cf-agent (default is every 5 minutes)
       ●   More sophisticated than cron (randomness, fail-safe operation, time exclusions)
●   cf-agent
       ●   The main component that does the system automation and maintenance (maintaining promises)
       ●   Runs cf-promises (another executable) to validate bundles/promise syntax
●   cf-serverd
       ●   Distributes policy and data files (cf-agent pulls from cf-serverd)
●   Hubs (Nova only), Servers and Clients
       ●   Can run standalone as well
       ●   All systems run the same configuration policies (Hubs/Servers are Clients too!)
       ●   Top-level system(s) get their files from version control (please say yes)
●   Promises (statements)
       ●   Describes the desired state of some aspect of a system (file, process, package...)
●   Bundles (collections of promises, aka policies)
       ●   promises.cf as bootstrap policy – says what other bundles to execute
●   Variables and Classes (CFEngine defined and User defined)
       ●   Classes are booleans that allow control over which promises are executed and when

             Copyright 2011 LearnThinkCode, Inc.
             This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Bundles
●   Bundles are typically designed to target a particular set of systems
    and/or a particular objective
●   Bundles have a type (which executable) and name
       ●   “common” is for all executables
       ●   Each bundle type has a control (configuration) promise body
●   Each bundle is run three times in order to get each promise fulfilled
    (convergence)
●   Bundles have sections (“promise type”) whose order is fixed based
    on the executable
●   promises.cf, failsafe.cf and update.cf are “standard”
●   cfengine_stdlib.cf has lots of the low level functionality
●   The “common control body” specifies the files to process and the
    bundle sequence – specified in promises.cf (or standalone files)


           Copyright 2011 LearnThinkCode, Inc.
           This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Bundles
●   Bundle promise type order (for agent)
       ●   vars – define variables
       ●   classes – define classes
       ●   outputs – (Nova) data collection
       ●   interfaces – network interfaces
       ●   files – files and file contents
       ●   packages – packages / libraries to install / uninstall
       ●   environments – (Nova) virtualization
       ●   methods – process other bundles
       ●   processes – processes that should / should not be running
       ●   services – collections of processes
       ●   commands – commands to execute
       ●   storage – disks and filesystems
       ●   databases – (Nova) LDAP, SQL and Windows Registry
       ●   reports – reporting on cfengine state

       Copyright 2011 LearnThinkCode, Inc.
       This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Variables and Classes
●   Variables
       ●    Special Variables (CFEngine defined)
       ●    Scalar types - string, int, real
       ●    List types - slist, ilist, rlist
       ●    Scalar expression ${var}, List expression @{var}
       ●    Scalar expression of a list is a loop / for-each
●   Classes
       ●    Booleans that guard promises
       ●    CFEngine-defined (aka hard) Classes
       ●    User-defined (aka soft) Classes
       ●    Often set by using built-in functions
       ●    Can also be defined by promise repair or failure
       ●    Combined with not ('!'), and ('.' or '&'), or ('|' or '||')
           Copyright 2011 LearnThinkCode, Inc.
           This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Promises
●   Within its promise type
    class-expression::
            “promiser” [→ {“promisee1”,...}]
                         attr1 => value1,
                         attr2 => value2, ...
                         attrN => valueN;
●   Promisee is only used by Nova
●   Promise body is all the attributes
●   Promise body may reference body-parts
●   Many common attributes, others based on type
       Copyright 2011 LearnThinkCode, Inc.
       This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Promises
●   File promise – edit_line bundle
        ●   Ability to handle file edits
        ●   Templates or line changes
●   Promise Body Parts
        ●   Reusable setup of promise attributes
        ●   Can take parameters / variables
        ●   Can use classes internally
●   Functions
        ●   Lots of built-in functions
        ●   Many functions return a class (boolean)
       Copyright 2011 LearnThinkCode, Inc.
       This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Example 1 – Java Setup
●
    Review tm-java.cf (a portion of tm.cf)
●
    Goal is to have Oracle Java (JDK) as java
●
    No RHEL repo for it




      Copyright 2011 LearnThinkCode, Inc.
      This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Example 2 – DB, Tomcat, HTTP
●
    Review tm-server.cf
●
    All install as packages
●
    All run as services
●
    Configuration and setup
         ●
             Httpd configuration as template
         ●
             Restart httpd if configuration changed
         ●
             Tomcat to run as non-root user
         ●
             Tomcat context copied in
         ●
             MySQL db creation as idempotent(?)
      Copyright 2011 LearnThinkCode, Inc.
      This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Example 3 – Web App Deploy
●   Review tm-webapps.cf
●   Web applications are built with Jenkins
●   Jenkins jobs configure which hosts get which builds
       ●   Save war with .<host> appended to name
●   CFEngine needs to know when to pick up the wars
    (and not catch them in the middle)
       ●   Trigger file with <host> name
●   Some applications require special files
●   And then unzip everything and restart Tomcat


       Copyright 2011 LearnThinkCode, Inc.
       This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
New Machine Setup
●   Review Entagen Triplemap Demo script
        ●   Quick script to bootstrap Triplemap Demos
        ●   Builds <x>.triplemap.com
        ●   Machine setup with KVM
●   Some VM support in Nova (I've not seen it)
●   Have seen knife (Chef) used to bring up
    CFEngine policy servers and clients
        ●   And then CFEngine to setup Puppet
        ●   And then Puppet to setup Chef
        ●   http://blog.afistfulofservers.net/
      Copyright 2011 LearnThinkCode, Inc.
      This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Challenges to CFEngine
●   Learning Curve
       ●   Syntax and flow in general
       ●   No “standard style”
       ●   Global vs Local on variables / classes
       ●   Reserved names
       ●   Timing / Locks
●   Large Ecosystem
       ●   Tons of variables, classes, functions
       ●   Start small! Collaborate!
       ●   Code review files in VCS!
●   Be careful – you are root everywhere at once!
       ●   cf-promises will verify syntax – it will not prevent stupid – test your files!
       ●   Use test.cf and limit its execution
       ●   Run on a virtual machine
       ●   Run your tests at least twice on a given machine

           Copyright 2011 LearnThinkCode, Inc.
           This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Copyright 2011 LearnThinkCode, Inc.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
CFEngine vs Chef vs Puppet
●   Chef and Puppet are both Ruby-based
●   CFEngine is C
       ●   Runs on anything (Nova) and is fast and lightweight (memory footprint)
       ●   CFEngine scales very well (AMD running 10k clients per server)
●   Commercial support available for all
       ●   Is “only in Nova” driving people away from CFEngine?
●   Execution repairs itself (failsafe/update) – don't know for Chef/Puppet
●   CFEngine language is “odd” - learning curve for all
●   CFEngine file editing capabilities seem strong (lots of body parts in stdlib)
●   CFEngine will be more verbose
       ●   but everything is available and easily tweakable (vs “Puppet defines the how”)
       ●   to an extent...promise types are written in C
●   CFEngine based on heuristics / Promise Theory vs Graph / Dependencies / Model
●   Lots of sharing of Chef recipes and Puppet scripts – not so much with CFEngine
       ●   Community Open Promise Body Library but that's it...
●   Puppet a reaction to CFEngine 2 (Luke Kanies) – CFEngine 3 is a rewrite
●   Chef a reaction to Puppet

             Copyright 2011 LearnThinkCode, Inc.
             This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
References
●
    CFEngine
         ●
             http://cfengine.com/getting-started
●
    Vertical SysAdmin (Aleksey)
         ●
             http://www.verticalsysadmin.com/blog
         ●
             http://www.verticalsysadmin.com/cfengine/
               Getting_Started_with_CFEngine_3.pdf
●
    Sample WordPress setup
         ●
             http://sysadvent.blogspot.com/2011/12/da
               y-15-automating-wordpress-with.html

      Copyright 2011 LearnThinkCode, Inc.
      This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
Q/A – Thank You!




   Copyright 2011 LearnThinkCode, Inc.
   This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Related Content

PPT
What is Java Technology (An introduction with comparision of .net coding)
PDF
PDF
J2EE vs JavaEE
PDF
invokedynamic: Evolution of a Language Feature
PDF
OSGi overview
PDF
Zend Framework 2 quick start
PDF
Java Course 13: JDBC & Logging
PDF
A quick start on Zend Framework 2
What is Java Technology (An introduction with comparision of .net coding)
J2EE vs JavaEE
invokedynamic: Evolution of a Language Feature
OSGi overview
Zend Framework 2 quick start
Java Course 13: JDBC & Logging
A quick start on Zend Framework 2

What's hot (20)

ODP
Jalimo Slides Linuxtag2007 (English)
PDF
Jax london 2011
PDF
Java SE 9 modules (JPMS) - an introduction
ODP
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
PDF
Disco API - OpenJDK distributions as a service
PDF
Java and Java platforms
PDF
Java SE 9 modules - an introduction (July 2018)
PDF
Taming the Deployment Beast
PDF
Java Course 15: Ant, Scripting, Spring, Hibernate
PDF
Jython for embedded software validation
PDF
Introduction to Android by Demian Neidetcher
PPTX
Dalvik Vm &amp; Jit
PDF
Zend Framework 2 Patterns
PDF
Zend Framework 2 - Basic Components
PDF
Architecture | Modular Enterprise Applications | Mark Nuttall
PDF
Agile Days Twin Cities 2011
PPTX
Java introduction
PDF
JVM JIT compilation overview by Vladimir Ivanov
PDF
Java 7 Modularity: a View from the Gallery
PPTX
How to implement a simple dalvik virtual machine
Jalimo Slides Linuxtag2007 (English)
Jax london 2011
Java SE 9 modules (JPMS) - an introduction
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Disco API - OpenJDK distributions as a service
Java and Java platforms
Java SE 9 modules - an introduction (July 2018)
Taming the Deployment Beast
Java Course 15: Ant, Scripting, Spring, Hibernate
Jython for embedded software validation
Introduction to Android by Demian Neidetcher
Dalvik Vm &amp; Jit
Zend Framework 2 Patterns
Zend Framework 2 - Basic Components
Architecture | Modular Enterprise Applications | Mark Nuttall
Agile Days Twin Cities 2011
Java introduction
JVM JIT compilation overview by Vladimir Ivanov
Java 7 Modularity: a View from the Gallery
How to implement a simple dalvik virtual machine
Ad

Viewers also liked (9)

ODP
Cfengine presentation at the RMLL
PDF
Config Management Camp 2015 - How to Deploy CFEngine in the Open Internet
ODP
CFEngine - company, mission, offering and partners
PDF
Configuration management 101 - A tale of disaster recovery using CFEngine 3
PDF
Configuration management: automating and rationalizing server setup with CFEn...
PPTX
Getting started with CFEngine - Webinar
PDF
Using ncf building blocks to help writing CFEngine policies
PDF
Cfengine presentation @Loadays
ODP
Cfengine vs Puppet vs Chef: A Guide for Stressed Developers
Cfengine presentation at the RMLL
Config Management Camp 2015 - How to Deploy CFEngine in the Open Internet
CFEngine - company, mission, offering and partners
Configuration management 101 - A tale of disaster recovery using CFEngine 3
Configuration management: automating and rationalizing server setup with CFEn...
Getting started with CFEngine - Webinar
Using ncf building blocks to help writing CFEngine policies
Cfengine presentation @Loadays
Cfengine vs Puppet vs Chef: A Guide for Stressed Developers
Ad

Similar to CFEngine 3 (20)

ODP
It gilde 20150209
PDF
Modularity problems
PDF
Vagrant & CFEngine - LOPSA East 2013
PDF
(phpconftw2012) PHP as a Middleware in Embedded Systems
PDF
DevOps Fest 2020. immutable infrastructure as code. True story.
PDF
It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching.
PDF
The State of the Veil Framework
PPTX
Build, logging, and unit test tools
PDF
CFEngine, 4 years later
PDF
Project Atomic-Nulecule
PDF
Don't Fear the Autotools
PDF
JOSA TechTalks - Docker in Production
PDF
Devops with Python by Yaniv Cohen DevopShift
PPTX
Getting Started With CFEngine - Updated Version
PDF
Shorten Device Boot Time for Automotive IVI and Navigation Systems
PPT
Managing Your Runtime With P2
PDF
Configuration Management and Transforming Legacy Applications in the Enterpri...
PDF
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
PDF
Best Practices for Developing & Deploying Java Applications with Docker
PDF
Em13c features- HotSos 2016
It gilde 20150209
Modularity problems
Vagrant & CFEngine - LOPSA East 2013
(phpconftw2012) PHP as a Middleware in Embedded Systems
DevOps Fest 2020. immutable infrastructure as code. True story.
It’s 2021. Why are we -still- rebooting for patches? A look at Live Patching.
The State of the Veil Framework
Build, logging, and unit test tools
CFEngine, 4 years later
Project Atomic-Nulecule
Don't Fear the Autotools
JOSA TechTalks - Docker in Production
Devops with Python by Yaniv Cohen DevopShift
Getting Started With CFEngine - Updated Version
Shorten Device Boot Time for Automotive IVI and Navigation Systems
Managing Your Runtime With P2
Configuration Management and Transforming Legacy Applications in the Enterpri...
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
Best Practices for Developing & Deploying Java Applications with Docker
Em13c features- HotSos 2016

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Machine learning based COVID-19 study performance prediction
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Spectral efficient network and resource selection model in 5G networks
Mobile App Security Testing_ A Comprehensive Guide.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
MIND Revenue Release Quarter 2 2025 Press Release
Diabetes mellitus diagnosis method based random forest with bat algorithm
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
sap open course for s4hana steps from ECC to s4
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Chapter 3 Spatial Domain Image Processing.pdf
Machine learning based COVID-19 study performance prediction

CFEngine 3

  • 1. CFEngine 3 Code Freeze 2012 Jan 12, 2012 Brian Repko http://www.learnthinkcode.com Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 2. Agenda ● Introduction to CFEngine ● What it is ● How it works ● Examples ● New Machine Setup ● CFEngine vs Chef vs Puppet Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 3. IANAS (sysadmin) ● My role has been as a developer / architect working with sysadmins to deploy our applications ● When automated, we have used cfengine ● This presentation will use cfengine configuration from Entagen (triplemap.com) for our examples ● Thanks to Frans Lawaetz! Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 4. CFEngine ● Systems Maintenance Tool ● Configures and automates large-scale IT infrastructure ● Ensures the availability, security and compliance of systems and applications ● Created by Mark Burgess (Ph.D in Theoretical Physics) ● CFEngine 1 – released in 1993 (at Oslo University / post-doc) ● CFEngine 2 – released in 1998 (Computer Immunology) ● CFEngine 3 – released in 2008 (Promise Theory) ● Two editions – Community (FOSS) and Nova (commercial) ● Nova has portal, reporting, native MS Mac/Windows mgmt, high- availability, virtualization, KM, commercial support ● Written in C, runs on all types of systems including mobile, tablet and embedded systems ● Tons of low-level functions and action configurations to reuse Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 5. Who uses it Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 6. Components ● cf-execd ● Cron-like lightweight daemon that runs cf-agent (default is every 5 minutes) ● More sophisticated than cron (randomness, fail-safe operation, time exclusions) ● cf-agent ● The main component that does the system automation and maintenance (maintaining promises) ● Runs cf-promises (another executable) to validate bundles/promise syntax ● cf-serverd ● Distributes policy and data files (cf-agent pulls from cf-serverd) ● Hubs (Nova only), Servers and Clients ● Can run standalone as well ● All systems run the same configuration policies (Hubs/Servers are Clients too!) ● Top-level system(s) get their files from version control (please say yes) ● Promises (statements) ● Describes the desired state of some aspect of a system (file, process, package...) ● Bundles (collections of promises, aka policies) ● promises.cf as bootstrap policy – says what other bundles to execute ● Variables and Classes (CFEngine defined and User defined) ● Classes are booleans that allow control over which promises are executed and when Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 7. Bundles ● Bundles are typically designed to target a particular set of systems and/or a particular objective ● Bundles have a type (which executable) and name ● “common” is for all executables ● Each bundle type has a control (configuration) promise body ● Each bundle is run three times in order to get each promise fulfilled (convergence) ● Bundles have sections (“promise type”) whose order is fixed based on the executable ● promises.cf, failsafe.cf and update.cf are “standard” ● cfengine_stdlib.cf has lots of the low level functionality ● The “common control body” specifies the files to process and the bundle sequence – specified in promises.cf (or standalone files) Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 8. Bundles ● Bundle promise type order (for agent) ● vars – define variables ● classes – define classes ● outputs – (Nova) data collection ● interfaces – network interfaces ● files – files and file contents ● packages – packages / libraries to install / uninstall ● environments – (Nova) virtualization ● methods – process other bundles ● processes – processes that should / should not be running ● services – collections of processes ● commands – commands to execute ● storage – disks and filesystems ● databases – (Nova) LDAP, SQL and Windows Registry ● reports – reporting on cfengine state Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 9. Variables and Classes ● Variables ● Special Variables (CFEngine defined) ● Scalar types - string, int, real ● List types - slist, ilist, rlist ● Scalar expression ${var}, List expression @{var} ● Scalar expression of a list is a loop / for-each ● Classes ● Booleans that guard promises ● CFEngine-defined (aka hard) Classes ● User-defined (aka soft) Classes ● Often set by using built-in functions ● Can also be defined by promise repair or failure ● Combined with not ('!'), and ('.' or '&'), or ('|' or '||') Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 10. Promises ● Within its promise type class-expression:: “promiser” [→ {“promisee1”,...}] attr1 => value1, attr2 => value2, ... attrN => valueN; ● Promisee is only used by Nova ● Promise body is all the attributes ● Promise body may reference body-parts ● Many common attributes, others based on type Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 11. Promises ● File promise – edit_line bundle ● Ability to handle file edits ● Templates or line changes ● Promise Body Parts ● Reusable setup of promise attributes ● Can take parameters / variables ● Can use classes internally ● Functions ● Lots of built-in functions ● Many functions return a class (boolean) Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 12. Example 1 – Java Setup ● Review tm-java.cf (a portion of tm.cf) ● Goal is to have Oracle Java (JDK) as java ● No RHEL repo for it Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 13. Example 2 – DB, Tomcat, HTTP ● Review tm-server.cf ● All install as packages ● All run as services ● Configuration and setup ● Httpd configuration as template ● Restart httpd if configuration changed ● Tomcat to run as non-root user ● Tomcat context copied in ● MySQL db creation as idempotent(?) Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 14. Example 3 – Web App Deploy ● Review tm-webapps.cf ● Web applications are built with Jenkins ● Jenkins jobs configure which hosts get which builds ● Save war with .<host> appended to name ● CFEngine needs to know when to pick up the wars (and not catch them in the middle) ● Trigger file with <host> name ● Some applications require special files ● And then unzip everything and restart Tomcat Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 15. New Machine Setup ● Review Entagen Triplemap Demo script ● Quick script to bootstrap Triplemap Demos ● Builds <x>.triplemap.com ● Machine setup with KVM ● Some VM support in Nova (I've not seen it) ● Have seen knife (Chef) used to bring up CFEngine policy servers and clients ● And then CFEngine to setup Puppet ● And then Puppet to setup Chef ● http://blog.afistfulofservers.net/ Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 16. Challenges to CFEngine ● Learning Curve ● Syntax and flow in general ● No “standard style” ● Global vs Local on variables / classes ● Reserved names ● Timing / Locks ● Large Ecosystem ● Tons of variables, classes, functions ● Start small! Collaborate! ● Code review files in VCS! ● Be careful – you are root everywhere at once! ● cf-promises will verify syntax – it will not prevent stupid – test your files! ● Use test.cf and limit its execution ● Run on a virtual machine ● Run your tests at least twice on a given machine Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 17. Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 18. CFEngine vs Chef vs Puppet ● Chef and Puppet are both Ruby-based ● CFEngine is C ● Runs on anything (Nova) and is fast and lightweight (memory footprint) ● CFEngine scales very well (AMD running 10k clients per server) ● Commercial support available for all ● Is “only in Nova” driving people away from CFEngine? ● Execution repairs itself (failsafe/update) – don't know for Chef/Puppet ● CFEngine language is “odd” - learning curve for all ● CFEngine file editing capabilities seem strong (lots of body parts in stdlib) ● CFEngine will be more verbose ● but everything is available and easily tweakable (vs “Puppet defines the how”) ● to an extent...promise types are written in C ● CFEngine based on heuristics / Promise Theory vs Graph / Dependencies / Model ● Lots of sharing of Chef recipes and Puppet scripts – not so much with CFEngine ● Community Open Promise Body Library but that's it... ● Puppet a reaction to CFEngine 2 (Luke Kanies) – CFEngine 3 is a rewrite ● Chef a reaction to Puppet Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 19. References ● CFEngine ● http://cfengine.com/getting-started ● Vertical SysAdmin (Aleksey) ● http://www.verticalsysadmin.com/blog ● http://www.verticalsysadmin.com/cfengine/ Getting_Started_with_CFEngine_3.pdf ● Sample WordPress setup ● http://sysadvent.blogspot.com/2011/12/da y-15-automating-wordpress-with.html Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License
  • 20. Q/A – Thank You! Copyright 2011 LearnThinkCode, Inc. This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License