Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:09:48+00:00 2026-06-06T08:09:48+00:00

Let’s say I have: $files = [file1, file2] exec { exec1 : command =>

  • 0

Let’s say I have:

$files = ["file1", "file2"]
exec { "exec1" :
    command => "mycommand";
}
file { $files :
    ensure => present;
}

And I want to use the -> and ~> constructs to control the notify/require order of execution, like so:

Exec["exec1"] -> File[$files]

How do I do it?

If I do the above, I get Could not find resource 'File[file1]File[file2]' (for real file paths, of course). I’ve played with wrapping the $files variable in quotes and {}s, but to no avail.

What’s the syntax for putting an array variable of resource names into an ordering chain?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:09:53+00:00Added an answer on June 6, 2026 at 8:09 am

    You can use the ‘What is in an array’ hint from this great list of hints from R.I.Pienaar:

    First define a function that handles the chaining, then pass in your array to the function.
    The function will get called once for each item in the array.

    Code sample time:

    exec { "exec1":
         command => "/bin/echo 'i am the very model of a modern major general'";
    }
    
    file { 
        "/var/tmp/file1":
            ensure => present;
        "/var/tmp/file2":
            ensure => present;
    }
    
    define chaintest() {
        notify{"Calling chaintest with ${name}": }
        Exec["exec1"] -> File["${name}"]
    }
    
    $files = ["/var/tmp/file1","/var/tmp/file2"]
    
    chaintest{$files: }
    

    The output of ‘puppet apply test.pp’ on puppet 2.7.11 on Ubuntu 12.04 gives:

    notice: Calling chaintest with /var/tmp/file1
    notice: /Stage[main]//Chaintest[/var/tmp/file1]/Notify[Calling chaintest with /var/tmp/file1]/message: defined 'message' as 'Calling chaintest with /var/tmp/file1'
    notice: /Stage[main]//Exec[exec1]/returns: executed successfully
    notice: Calling chaintest with /var/tmp/file2
    notice: /Stage[main]//Chaintest[/var/tmp/file2]/Notify[Calling chaintest with /var/tmp/file2]/message: defined 'message' as 'Calling chaintest with /var/tmp/file2'
    notice: Finished catalog run in 0.11 seconds
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have a drive such as C:\ , and I want to
Let's say I have thousands of users and I want to make the passwords
Let's say I want to have some kind of a cache that did something
Let's say we have this code: <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input
Let's say i have two tables in db: Car and Part. Car owns arbitrialy
Let’s say I have a number like 0x448 . In binary this is 0100
Let's say I have a 12-bit Analog to Digital Converter (4096 bins). And let's
Let's say I have a structure named vertex with a method that adds two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.