akshay
akshay

Reputation: 29

How to add multiple source in one class in puppet manifest and how to declare that?

class practice_oracle
{
$files_inst = [
/tmp/packages/compat-libstdc++-33-3.2.3-47.3.x86_64.rpm,
/tmp/packages/elfutils-libelf-0.125-3.ML5.x86_64.rpm,
/tmp/packages/elfutils-libelf-devel-0.125-3.ML5.x86_64.rpm,
/tmp/packages/gcc-4.6.3-2.fu2012.x86_64.rpm,
/tmp/packages/gcc-c++-4.6.3-2.fu2012.x86_64.rpm,
/tmp/packages/glib2-2.28.8-1.fc15.x86_64.rpm,
]
file {
$files_inst:
ensure => present,
owner => root,
group => root,
mode => 0755,
source => "puppet:///modules/practice_oracle/compat-libstdc++-33-32.3-47.3.x86_64.rpm",
source =>puppet:///modules/practice_oracle/elfutils-libelf-0.125-3.ML5.x86_64.rpm",
source => "puppet:///modules/practice_oracle/elfutils-libelf-devel-0.125-3.ML5.x86_64.rpm",
source => "puppet:///modules/practice_oracle/gcc-4.6.3-2.fu2012.x86_64.rpm",
source => "puppet:///modules/practice_oracle/gcc-c++-4.6.3-2.fu2012.x86_64.rpm",
}

In this code I m try to write multiple source and then I run on agent machine but when running this script on agent machine then it take the same size for all the packages whichever first in the list.
so what code write for this script and what are the mistakes in this my code. Please help me for that question.

Upvotes: 1

Views: 762

Answers (2)

Felix Frank
Felix Frank

Reputation: 8223

In your specific case: what ptierno said.

Generally, create a utility defined type:

define remote_file($dest_dir='/tmp/packages', $module='practice_oracle') {
    file {
        "$dest_dir/$title":
            ensure => present,
            owner => root,
            group => root,
            mode => 0755,
            source => "puppet:///modules/$module/$title",
    }
}

And just

remote_file { $file_inst: }

Upvotes: 0

ptierno
ptierno

Reputation: 10074

The way you are going about this will not work. However, the file type does have a recurse option for use with directories. You can use this as follows:

Example
file { '/tmp/packages':
  ensure  => directory,
  source  => 'puppet://modules/practice_oracle",
  owner   => 'root',
  group   => 'root',
  mode    => '0755',
  recurse => true
}

This will populate the /tmp/packages directory with the entire directory contents of ${::modulepath}/practice_oracle/files.

Reference

https://docs.puppetlabs.com/references/latest/type.html#file-attribute-recurse

Hope this helps

Upvotes: 3

Related Questions