Ask Your Question
1

include regex or wildcard in file path specification

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

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
1

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

Ancillas gravatar image

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

I don't think puppet accepts regex for directories like that, but you could try something like this.

copy_drivers.sh (you'd want to add lots of error checking)

#!/bin/bash

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

source_files_root="${1}/*"
dest_root="${2}/*"

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

Puppet

# 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/copy_drivers.sh':
  ensure => present,
  owner  => 'root',
  group  => 'root',
  mode ...
(more)
edit flag offensive delete link more

Comments

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 -0500 )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

Stats

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

Seen: 3,692 times

Last updated: Jul 10 '13