Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

get list of directory subdirectories

$
0
0
Hi! I am trying to create a custom fact that returns the list of subdirectories within a subdirectory, if the subdirectory exists. For example, if the computer has `/data/files`, I need to obtain all the subdirectories inside it (`/data/files/one, /data/files/two, /data/files/three`), without the prefix path (so just (`one two three`). I tried to write a custom fact but I am failing woefully, Facter.add(:datasubdirs) do result = '' setcode do if File.directory? '/data/files' do |str| Facter::Util::Resolution.exec('/bin/ls /data/files/') result += str end end end end Please what am I doing wrong and how can I make it better?

Viewing all articles
Browse latest Browse all 6104

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>