安装R10K puppetfile而不清除自定义模块

时间:2017-07-07 14:35:24

标签: puppet

我制作了一些自定义模块。

这些自定义模块存储在我的R10K control-repo中。因此,如果我运行R10K deploy environment,则模块位于/etc/puppetlabs/code/environments/MY_BRANCH/modules/并正常工作。

我现在想要使用Puppet Forge中的一些模块,所以我将它们添加到我的Puppetfile,但是当我运行r10k puppetfile install时,模块目录被完全清除,只有木偶伪造模块留下。

最佳解决方案是什么?

在:

-modules/
  -custom_facts/
  -custom_files/

后:

-modules/
  -certregen/
  -inifile/

所需:

 -modules/
  -custom_facts/
  -custom_files/
  -certregen/
  -inifile/

1 个答案:

答案 0 :(得分:2)

Puppetfile中的模块安装有一个不太知名的选项。它是local选项:https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#local

您可以在true中将其设置为Puppetfile,以避免清除存储在控制回购中的模块:

mod 'custom_facts', local: true
mod 'custom_files', local: true

修改上述Puppetfile后,使用r10k deploy display确认结果令人满意。

请注意,另一个选项是将本地模块移动到另一个模块目录中。例如:

repo root dir
|── Puppetfile
|── local_modules
|   |── custom_facts
|   |── custom_files

R10k将在模块部署期间忽略该目录(但在控制仓库的环境部署期间不会),并且不会清除模块。但是,您需要设置enviroment.conf以查找其他路径中的模块:https://docs.puppet.com/puppet/5.0/config_file_environment.html#modulepath

相关问题