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 8730199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:58:15+00:00 2026-06-13T08:58:15+00:00

I would like to iterate over an array that is stored as a Facter

  • 0

I would like to iterate over an array that is stored as a Facter fact, and for each element of the array create a new system user and a directory, and finally make API calls to AWS.

Example of the fact: my_env => [shared1,shared2,shared3]

How can I iterate over an array in Puppet?

  • 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-13T08:58:16+00:00Added an answer on June 13, 2026 at 8:58 am

    This might work, depending on what you are doing

    # Assuming fact my_env => [ shared1, shared2, shared3 ]
    
    define my_resource {
      file { "/var/tmp/$name":
        ensure => directory,
        mode   => '0600',
      }
      user { $name:
        ensure => present,
      }
    }
    my_resource { $my_env: }
    

    It will work if your requirements are simple, if not, Puppet makes this very hard to do. The Puppet developers have irrational prejudices against iteration based on a misunderstanding about how declarative languages work.

    If this kind of resource doesn’t work for you, perhaps you could give a better idea of which resource properties you are trying to set from your array?

    EDIT:

    With Puppet 4, this lamentable flaw was finally fixed. Current state of affairs documented here. As the documentation says, you’ll find examples of the above solution in a lot of old code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to iterate through an array that covers every pixel on my
In a shell script I'm looking to iterate over an array like I would
I would like to iterate over the data rows stored in a Zend_Db_Table_Rowset object
I would like to iterate over a collection and at the same time also
i would like to iterate over the items of a List<T> , except the
I would like to randomly iterate through a range. Each value will be visited
I would like to convert the following string into an array/nested array and iterate
I am using Ruby on Rails 3.0.7 and I would like to iterate over
I was making a "concatenating iterator", i.e. an iterator that would iterate over the
I want to create a handlebars helper that works like {{#each}} but gives me

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.