Puppet [SOLVED]: Puppet Class: define a variable which list all files in a directory

Puppet [SOLVED]: Puppet Class: define a variable which list all files in a directory

Home Forums Automation Tools Puppet Puppet [SOLVED]: Puppet Class: define a variable which list all files in a directory

Tagged: , ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #241079

    Cloudy Point
    Keymaster

    QuestionQuestion

    I’m defining my own Puppet class, and I was wondering if it is possible to have an array variable which contains a list of all files in a specific directory. I was wondering to have a similar syntax like below, but didn’t found a way to make it work.

    $dirs = Dir.entries('C:\Program Files\Java\')
    

    Does anyone how to do it in a Puppet file?

    Thanks!

    #241080

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    I was wondering if it is possible to have an array variable which contains a list of all files in a specific directory.

    Information about the current state of the machine to be configured is conveyed to the catalog compiler via facts. These are available to your classes as top-scope variables, and Puppet (or Facter, actually) provides ways to define your own custom facts. That’s a link into the Facter 3 manual, but similar applies to earlier versions. Do not overlook the rest of the Facter documentation, which has more relevant information on this topic.

    On the other hand, information about the machine providing catalog-building services — the master in a master / agent setup — can be obtained by writing and calling a custom function. This is rarely what you actually want, but it’s worth mentioning because you might one day want a custom function for some other purpose.

    Source: https://stackoverflow.com/questions/47795075/puppet-class-define-a-variable-which-list-all-files-in-a-directory
    Author: John Bollinger
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.