使用数组中的粒子名称连接文件的内容

时间:2013-07-04 08:35:00

标签: puppet

我在dir中有很多文件(在master上),名称为file1.domain file2.domain file3.domain someanothername.domain 域总是一样的。

我需要定义类型,我可以像这样使用。

mydefinedtype { "title":
    filenames => ["file1", "file2", "file3"],
    }

它将在节点上创建包含文件内容的文件 file1.domain file2.domain file3.domain

1 个答案:

答案 0 :(得分:0)

我猜你的意思是你想要在节点中部署一些文件。

如果是这样,您可以执行以下操作。这会将file1,2,3从your_module / files复制到目标目录:

$filenames = ["file1", "file2", "file3"]

define copy_file {
  file { "/targetdir/$name":
    source => 'puppet:///modules/your_module/$name',
  }
}

copy_file { $filenames }

请参阅:http://docs.puppetlabs.com/guides/file_serving.html