Jesse,

The URL helped.  Thanks.

Here are my files that may help others.

/tmp/templates/seed_file_list.cf
"/tmp/test/create_folder1/create_file4.txt
/tmp/test/create_folder1/create_folder2/create_file5.txt
/tmp/test/create_folder1/create_folder3/create_file6.txt"

/tmp/templates/variables.cf
"bundle common inputVars
{
        vars:
                "paths" slist           => { 
"/tmp/test/create_folder1/create_folder2/." , 
"/tmp/test/create_folder1/create_folder3/." };
                "fnames" slist          => { 
"/tmp/test/create_folder1/create_file4.txt" , 
"/tmp/test/create_folder1/create_folder2/create_file5.txt" , 
"/tmp/test/create_folder1/create_folder3/create_file6.txt" };
                "flist" slist           => { 
readstringlist("/tmp/templates/seed_file_list.cf", "#.*", "\n", 99999999999, 
99999999999) };
}"

/tmp/templates/create_local_file_with_variables_on_file_reading_seed_file.cf
"#
#       testing cfengine with following:
#               file copy
#               variable
#               seed file
#
body common control
{
        bundlesequence          => { createFile(@(inputVars.flist)) };
        ignore_missing_bundles  => "true";
        require_comments        => "true";
        inputs                  => { "/var/cfengine/inputs/cfengine_stdlib.cf" 
, "/tmp/templates/variables.cf" };
        version                 => "1.0";
}

body agent control
{
        verbose         => "true";
}

bundle agent createFile(x)
{
        files:
#
#       the stanza below creates folders and file if it does not exist
#
                "$(x)"
                comment => "create file",
                perms => mog("755", "root", "root"),
                create => "true";

}"

Regards,
J

-----Original Message-----
From: Jesse Becker [mailto:becker...@mail.nih.gov] 
Sent: Wednesday, June 08, 2011 12:54 PM
To: Jerome Yanga
Cc: 'help-cfengine@cfengine.org'
Subject: Re: Cfengine Help: Creating folders via input file or variable cf file

Take a look at readstringlist():

http://www.cfengine.org/manuals/cf3-reference.html#Function-readstringlist

On Wed, Jun 08, 2011 at 03:36:37PM -0400, Jerome Yanga wrote:
>Thank you, Neil.
>
>With your direction, I got this to work with the variables.cf.  However, it is 
>quite a pain to create a slist variable with 150 elements.  Is it possible to 
>read a file with a list of 150 folder names?  I am sure that I can create a 
>script that creates this variable file but I am just hoping that Cfengine can 
>just read a list in a file.
>
>Here are my cf files.
>
>/tmp/templates/variables.cf
>"bundle common inputVars
>{
>        vars:
>                "paths" slist           => { 
> "/tmp/test/create_folder1/create_folder2/." ,
>                                                
> "/tmp/test/create_folder1/create_folder3/." };
>}"
>
>/tmp/templates/create_local_folder_with_variables_on_file.cf
>"#       testing cfengine with the following:
>#               folder copy
>#               externaml variable file
>#
>body common control
>{
>        bundlesequence          => { createFolder(@(inputVars.paths)) };
>        ignore_missing_bundles  => "true";
>        require_comments        => "true";
>        inputs                  => { "/var/cfengine/inputs/cfengine_stdlib.cf" 
> , "/tmp/templates/variables.cf" };
>        version                 => "1.0";
>}
>
>body agent control
>{
>        verbose         => "true";
>}
>
>bundle agent createFolder(x)
>{
>        files:
>                "$(x)"
>                comment => "create dir",
>                perms => mog("755", "root", "root"),
>                create => "true";
>}"
>
>Regards,
>j
>
>-----Original Message-----
>From: help-cfengine-boun...@cfengine.org 
>[mailto:help-cfengine-boun...@cfengine.org] On Behalf Of no-re...@cfengine.com
>Sent: Wednesday, June 08, 2011 7:51 AM
>To: help-cfengine@cfengine.org
>Subject: Cfengine Help: Creating folders via input file or variable cf file
>
>Forum: Cfengine Help
>Subject: Re: Cfengine Help: Cannot copy files to remote host
>Author: neilhwatson
>Link to topic: https://cfengine.com/forum/read.php?3,22342,22395#msg-22395
>
>Variables are scoped locally.  Your call for the paths list in the bundle 
>createFolder expects a local variable in that bundle.  That is where you 
>should create that list not in a separate bundle.  If a variable is likely to 
>be used in multiple bundles then you can define the variable in the a common 
>bundle.  Common variables are called via ${bundlename.variablename}.
>
>Further reading:
>http://www.cfengine.org/manuals/cf3-reference.html#List-variable-substitution-and-expansion
>http://www.cfengine.org/manuals/cf3-tutorial.html#Scalar-variable-expansion
>http://watson-wilson.ca/2011/05/managing-crontables-with-cfengine.html
>
>_______________________________________________
>Help-cfengine mailing list
>Help-cfengine@cfengine.org
>https://cfengine.org/mailman/listinfo/help-cfengine
>
>_______________________________________________
>Help-cfengine mailing list
>Help-cfengine@cfengine.org
>https://cfengine.org/mailman/listinfo/help-cfengine

-- 
Jesse Becker
NHGRI Linux support (Digicon Contractor)

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

Reply via email to