简体   繁体   English

如何在puppet清单中的一个类中添加多个源以及如何声明?

[英]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. 请帮我解决这个问题。

The way you are going about this will not work. 你这样做的方式是行不通的。 However, the file type does have a recurse option for use with directories. 但是, file类型确实有一个recurse选项用于目录。 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 . 这将使用${::modulepath}/practice_oracle/files的整个目录内容填充/tmp/packages目录。

Reference 参考

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

Hope this helps 希望这可以帮助

In your specific case: what ptierno said. 在你的具体案例中:ptierno说的是什么。

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: }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM