Forum: Cfengine Help
Subject: Re: How to make a policy server watch a subversion server for changes?
Author: danders5
Link to topic: https://cfengine.com/forum/read.php?3,17833,17834#msg-17834

I use a cfengine policy to update my subversion...  Below is basically what I 
have.

then I use a exec_command like the following for policy server machines.

my subversion repository 
/trunk is the development repository
/tags/production is the tag that 99% of the systems use.


So when I update trunk it immediately goes out to test systems, and then once 
up roll the changes up to the production tag the real systems get it.   



exec_command => "/usr/sbin/cf-agent -f failsafe.cf; /usr/sbin/cf-agent -f 
policy_svn.cf; /usr/sbin/cf-agent";


Below is my svn update policy file.  It has my cfengine2 and cfengine3 policy 
in seperate directories. 

##policy_svn.cf

#
# Special cfengine policy set for updating the policy from the svn server
#
body common control
{
    

    inputs => { "classes.cf", "cfengine_stdlib.cf" };

    policy_servers::
        bundlesequence => { "svn_package", "svn_checkout", "svn_update" };
    !policy_servers::
        bundlesequence => { "svn_not_policyhost" };
}


bundle common defaults
{
    vars:
        "dcs_repos_base" string => "/usr/dcs/cfengine";
        "repos_base" string => "/usr/engr/cfengine";
        "svn_account" string => "svc-cfengine";
        "svn_password" string => "intentionallyblank";
        "svn_options" string => "--username=$(svn_account) 
--password=$(svn_password) --no-auth-cache --non-interactive";
        "svn_url" string => "https://subversion.cs.illinois.edu/svn/cfengine3";;
        "dcs_svn_url" string => 
"https://subversion.cs.illinois.edu/svn/cfengine";;

    classes:
        "has_repos_base" expression => isdir("$(defaults.repos_base)");
        "need_devel_repos" not => isdir("$(defaults.repos_base)/development");
        "need_prod_repos" not => isdir("$(defaults.repos_base)/production");
        "has_dcs_repos_base" expression => isdir("$(defaults.dcs_repos_base)");
        "need_dcs_devel_repos" not => 
isdir("$(defaults.dcs_repos_base)/development");
        "need_dcs_prod_repos" not => 
isdir("$(defaults.dcs_repos_base)/production");
}

bundle agent svn_not_policyhost
{
    reports:
        !policy_servers::
            "This is not a policy host system and shouldn't execute this 
policy";
}

bundle agent svn_package
{
    packages:
        linux::
            "subversion"
                package_policy => "add",
                package_method => generic;
            
}
bundle agent svn_checkout
{

    commands:
        #
        # Engineering CFEngine 3 repository - /usr/engr/cfengine
        #
        need_devel_repos.has_repos_base.linux::
            "/usr/bin/svn co $(defaults.svn_options) $(defaults.svn_url)/trunk 
development"
                contain => in_dir("$(defaults.repos_base)"); 

        need_prod_repos.has_repos_base.linux::
            "/usr/bin/svn co $(defaults.svn_options) 
$(defaults.svn_url)/tags/production production"
                contain => in_dir("$(defaults.repos_base)"); 

        #
        # DCS cfengine 2 repository - /usr/dcs/cfengine
        #
        need_dcs_devel_repos.has_dcs_repos_base.linux::
            "/usr/bin/svn co $(defaults.svn_options) 
$(defaults.dcs_svn_url)/trunk development"
                contain => in_dir("$(defaults.dcs_repos_base)"); 

        need_dcs_prod_repos.has_dcs_repos_base.linux::
            "/usr/bin/svn co $(defaults.svn_options) 
$(defaults.dcs_svn_url)/tags/production production"
                contain => in_dir("$(defaults.dcs_repos_base)"); 

}

bundle agent svn_update
{

    commands:
        # 
        # Engineering CFengine3 repository - /usr/engr/cfengine 
        #
        !need_devel_repos.has_repos_base.linux::
            "/usr/bin/svn $(defaults.svn_options) update"
                contain => in_dir("$(defaults.repos_base)/development");

        !need_prod_repos.has_repos_base.linux::
            "/usr/bin/svn $(defaults.svn_options) update"
                contain => in_dir("$(defaults.repos_base)/production");
        
        #
        # DCS CFEngine 2 repository - /usr/dcs/cfengine
        #
        !need_dcs_devel_repos.has_dcs_repos_base.linux::
            "/usr/bin/svn $(defaults.svn_options) update"
                contain => in_dir("$(defaults.dcs_repos_base)/development");

        !need_dcs_prod_repos.has_dcs_repos_base.linux::
            "/usr/bin/svn $(defaults.svn_options) update"
                contain => in_dir("$(defaults.dcs_repos_base)/production");
        
}


- Show quoted text -
-- 
David Anderson
mr.anderson....@gmail.google.com

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

Reply via email to