Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Give an alias for a file seems to work. As example, the file which the name "tomcat_dir" could be used for next steps with " require => File["tomcat_dir"] " :

    file {"tomcat_dir":
            ensure  => directory,
            path    => "/usr/local/tomcat",
            mode    => "755",
            owner   => "tomcat",
            group   => "65534",
            recurse => true,
            require => [ Exec["tomcat_unzip"] ],
    }

But, if I do this :

    file { [ "/usr/local/tomcat", "/usr/local/tomcat/dir1", "/usr/local/tomcat/dir2", "/usr/local/tomcat/dir3", "/usr/local/tomcat/dir4"]:
            ensure  => directory,
            mode    => "755",
            owner   => "tomcat",
            group   => "65534",
            require => [ Exec["tomcat_untar"] ],
    }

How could I said Exec["test_unzip"] requires " file { [ "/usr/local/tomcat/dir1", "/usr/local/tomcat/dir2", "/usr/local/tomcat/dir3", "/usr/local/tomcat/dir4"] " without copy/paste all the paths?

    exec {"test_unzip":
            cwd     => "/usr/local/tomcat/dir1",
            command => "/usr/bin/unzip /tmp/${tomcat_zip_name}",
            unless  => "test -f /usr/local/jboss${version}/server/boursorama-${application}/version-${container_version}",
            require => [ !!!!!!!!!!!!!!! ],
    }

Because, if I modify some paths, I must modify in all "require" I use in my class!

Thanks!

share|improve this question
    
Have you tried making the path parameter the array of directories? –  Handyman5 Oct 15 '11 at 8:46

3 Answers 3

up vote 2 down vote accepted

Do this:

file { [ "/usr/local/tomcat", "/usr/local/tomcat/dir1", "/usr/local/tomcat/dir2", "/usr/local/tomcat/dir3", "/usr/local/tomcat/dir4"]:
        ensure  => directory,
        mode    => "755",
        owner   => "tomcat",
        group   => "65534",
        require => Exec["tomcat_untar"],
        before  => Exec['test_unzip'],
}

So that you don't have to change test_unzip.

share|improve this answer

Well, to keep the same structure, you could declare the directory list as a variable, then both declare and require with that variable.

But, that sounds really messy - why not have the parent directory (/usr/local/tomcat) require the subdirectories (and define them en masse), then either have it notify the exec, or have the exec subscribe to (or require) the parent directory?

There's a lot of tools at your disposal in the language to create the process flow and dependency structure that you need, and brute force with a list may not be the best solution for you.

share|improve this answer

If a resource requires several other resources, you must declare that requirement. There's no way around that.

In your case, though, I don't see why that exec you've specified requires any more than /usr/local/tomcat/dir1.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.