Forum: CFEngine Help
Subject: separate dev/production environments
Author: Tim
Link to topic: https://cfengine.com/forum/read.php?3,26169,26169#msg-26169

Hi,

We have an existing Cfengine2 installation, that uses separate development and 
production environments under Subversion control.  I am new to Cfengine3, and 
beginning work on porting our Cfengine2 infrastructure to Cfengine3.  I am 
using Cfengine Community v-3.3.3.

To illustrate a question I have on this, please consider the following code 
snippets that do not yet incorporate separate environments:

################################################
# In /var/cfengine/inputs/promises.cf
body common control
{
 bundlesequence => { "main", "test1", ... };
}
 inputs => { "cfengine_stdlib.cf", "cftest1.cf", ... };
}

################################################
# /var/cfengine/inputs/cftest1.cf
bundle agent test1
{  
files:
  "/tmp/cf_test_file"
      comment => "Promise that a plain file exists with stated permissions",
        perms => mog("644", "root", "sys"),
       create => "true";
}

Using "Chapter 6: Advanced Topics" of the Learning Cfengine 3 book as reference,
my first attempt to port the above into separate environments using version 
control
follows:

###############################################################################
# In /var/cfengine/inputs/promises.cf
body common control
{
        inputs => {
                        "cfengine_stdlib.cf",
                        "environment_$(environments.active)/env_promises.cf",
                        "environment_$(environments.active)/cftest1.cf",
                  };
        bundlesequence => {
                                "environments",
                                "main",
                                "env_main",
                                "test1",
}

###############################################################################
# In /var/cfengine/inputs/promises.cf
bundle common environments
{
  classes:
      "environment_development" expression => fileexists( 
"/DevelopmentFlagFile" );
      "environment_production" expression => fileexists( "/ProductionFlagFile" 
);
  vars:
    any::
      "active" string => "none", policy => "overridable";
    environment_production::
      "active" string => "production", policy => "overridable";
    environment_development::
      "active" string => "development", policy => "overridable";
}


###############################################################################
# /var/cfengine/inputs/environment_development/env_promises.cf
bundle agent env_main
{
  reports:
    cfengine::
      "Environment: $(environments.active)";
}

I am planning to have the "inputs/environment_development" location be a 
Subversion trunk, and the "inputs/environment_production" location be a 
Subversion branch. One problem with the above Cfengine layout with respect to 
this is that /var/cfengine/inputs/promises.cf won't be under Subversion control.

If I could move the inputs and bundlesequence from "body common control" in 
inputs/promises.cf to 
"inputs/environment_$(environments.active)/env_promises.cf", I may not need 
promises.cf under Subversion control.  Would it be recommended to do this?   
And if so, how best to implement?   It is not valid to have additional inputs 
and bundlesequence declarations is "bundle agent env_main", correct?

Alternatively, is there a different approach to implementing separate 
environments that I should be considering?

Thanks.

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to