我有Windows代理节点。 我正在创build自己的模块,它有一些自定义的PowerShell脚本。 我想知道我应该在哪里保留这些PowerShell脚本。 在我的模块本身在一些文件夹(比如scripts目录)或者我的模块目录之外的地方? 在这种情况下,推荐/最佳做法是什么?
git/ - client - hieradata - manifests - modules - my_module - scripts/ # 1) Should it be within this dir? - my_script.ps1 - scripts/ # 2) Should it be within this dir or elsewhere? - my_script.ps1 - templates
一个模块可以附带自己的文件和模板 :
[modules_root] my_module files my_script manifests init.pp templates other_script.erb
由于OP发布build议安装模板的范围之外,…我觉得有必要也注意到,我们将安装这些:
file { "/etc/toto": source => "puppet:///modules/my_module/my_script"; "/etc/tata": content => template("my_module/other_script.erb"); }
模块是自包含的代码和数据捆绑。 您可以从Puppet Forge下载预build模块,也可以编写自己的模块。
根据官方文档 ,没有任何“好”的做法,在哪里把你的个人脚本的自定义模块。
但是,文件夹files可以包含包含静态文件,哪些受pipe节点可以下载 ,这是放置一些个人脚本的最接近的地方。
你也可以创build一个脚本文件夹,如果你认为这个脚本文件夹足够清晰,让其他人阅读并理解你的模块。
On disk, a module is simply a directory tree with a specific, predictable structure: - manifests - files - templates - lib - facts.d - examples - spec - functions - types
根据更一般的最佳做法,我build议你阅读这个 。
您应该存储这些脚本的唯一地方是在模块的files目录中。
然后可以使用file资源的source参数来部署脚本,如下所示:
file {'myfile': ensure => file, source => 'puppet:///modules/mymodule/myfile', }