Forum: CFEngine Help
Subject: Re: Var in var : limitation ?
Author: loopx
Link to topic: https://cfengine.com/forum/read.php?3,26678,26689#msg-26689

I fixed my problem like this :


bundle agent subversion {
        vars:
                subversion::
                        "service" string => "$(g.service_detected)";
                        "path_repository_default" string => 
"/mnt/data1/subversion";

                servers_management::
                        "repositories_$(service)"
                                slist => {
                                        "$(path_repository_default)/cfengine3"
                                };


# Only for DEBUG
#       reports:
#               subversion::
#                       "Defined repositories = '$(repositories_$(service))'";


        files:
                subversion::
                        "/svn"
                                link_from       => 
ln_s("$(path_repository_default)"),
                                comment         => "Symlink for easy 
repositories usage from remote machines";

                        # Subversion's Hooks (copy 'post-commit' + symlink for 
'post-revprop-change') #############################################
                        "$(repositories_$(service))/hooks/post-commit"
                                comment         => "Copy 'post-commit' hook 
(from repositories set for the service)",
                                copy_from       => 
no_backup_rcp("$(g.location_services)/$(service)/$(repositories_$(service))/hooks/post-commit",
 "$(sys.policy_hub)"),
                                perms           => mog(750, "root", "cfadmin");

...
}


In fact, I have one configuration file "subversion.cf". I want to copy "hooks" 
(if exists) from a path like this : 
"/var/cfengine/data/services//mnt/data1/subversion//hooks/post-commit".

I want to make a generic code and so, I have to use a var in var 
(repositories_) to made the promise. At the first time, it was working fine 
without any problem but since I wanted to move the "service" to 
"g.service_detected" (hardcoded only at one place : global.cf) but since that 
move, it fails. So, now, I get the value of the g.service_detected to the local 
var "service" and, no more problem at all :D.

And the question was : why ? What's the difference between global and local var 
? Why was it working before and not now ? (before this fix)


Thanks for your help

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

Reply via email to