Ask Your Question

Revision history [back]

1)

This is probably what you're after:

Puppet 3.x:

define freshlocalbin () {
  file { $name:
    ensure => present,
    path   => "/usr/local/bin/$name",
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
    source => "puppet:///modules/profiles/freshlocalbin/$name",
  }
}

$files = ['cls', 'chenv']
freshlocalbin($files)

Puppet 4.x:

$files = ['cls', 'chenv']
$files.each |String $file| {
  file { $file:
    ensure => present,
    path   => "/usr/local/bin/$file",
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
    source => "puppet:///modules/profiles/freshlocalbin/$file",
  }
}

2)

No I think you want this.

1)

This is probably what you're after:

Puppet 3.x:

define freshlocalbin () {
  file { $name:
    ensure => present,
    path   => "/usr/local/bin/$name",
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
    source => "puppet:///modules/profiles/freshlocalbin/$name",
  }
}

$files = ['cls', 'chenv']
freshlocalbin($files)

Puppet 4.x:

$files = ['cls', 'chenv']
$files.each |String $file| {
  file { $file:
    ensure => present,
    path   => "/usr/local/bin/$file",
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
    source => "puppet:///modules/profiles/freshlocalbin/$file",
  }
}

2)

No I think If you want this.

to recursively manage directories, and purge unmanaged files:

file { '/some/dir':
  ensure => directory,
  recurse => true,
  purge => true,
  source => 'puppet://file_server/some/dir',
}

1)

This is probably what you're after:

Puppet 3.x:

define freshlocalbin () {
  file { $name:
    ensure => present,
    path   => "/usr/local/bin/$name",
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
    source => "puppet:///modules/profiles/freshlocalbin/$name",
  }
}

$files = ['cls', 'chenv']
freshlocalbin($files)

Puppet 4.x:

$files = ['cls', 'chenv']
$files.each |String $file| {
  file { $file:
    ensure => present,
    path   => "/usr/local/bin/$file",
    mode   => '0755',
    owner  => 'root',
    group  => 'root',
    source => "puppet:///modules/profiles/freshlocalbin/$file",
  }
}

2)

If you want to recursively manage directories, and purge unmanaged files:

file { '/some/dir':
  ensure  => directory,
  recurse => true,
  purge  => true,
  source  => 'puppet://file_server/some/dir',
}