Ask Your Question

include regex or wildcard in file path specification

asked 2013-07-09 17:45:12 -0600

BaltoStar gravatar image

Is it possible to include a wildcard or regex in a file path specification ?

So, for example, i want to copy a file into dirs lp0001.webdriver , lp0002.webdriver , etc.

file {'driver1':
  path    => '//etc/drivers/*.webdriver/driver1',
  ensure  => present,
  source  => "puppet:///modules/files/webdrivers/driver1",
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-07-10 02:53:48 -0600

Ancillas gravatar image

updated 2013-07-10 02:54:28 -0600

I don't think puppet accepts regex for directories like that, but you could try something like this. (you'd want to add lots of error checking)


# copies all files in source_files_root to each first level subdir in dest_root


find ${dest_root} -type d -maxdepth 0 -exec cp ${source_files_root} {} \;


# copy driver dir to client temp dir
file { '/tmp/drivers':
  ensure  => directory,
  recurse => true,
  purge   => true,
  force   => true,
  owner   => 'root',
  group   => 'root',
  mode    => '0644',
  source  => 'puppet:///drivers/',

# distribute copy script to client
file { '/tmp/':
  ensure => present,
  owner  => 'root',
  group  => 'root',
  mode ...
edit flag offensive delete link more


Taking a second look, you could probably just call 'find' in the Exec resource instead of wrapping the operation in a script. It's far too late to be writing code :).

Ancillas gravatar imageAncillas ( 2013-07-10 02:55:25 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-07-09 17:45:12 -0600

Seen: 4,437 times

Last updated: Jul 10 '13