从清单脚本安装 puppet 模块 [英] Installing a puppet module from a manifest script

查看:42
本文介绍了从清单脚本安装 puppet 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 puppet 来配置一个 vagrant(基于 ubuntu)的虚拟机.在我的脚本中,我需要:

I'm using puppet to provision a vagrant (ubuntu based) virtual machine. In my script I need to:

sudo apt-get build-dep python-lxml

我知道我可以安装 apt puppet 模块,所以我可以使用:

I know I can install the apt puppet module so I can use:

apt::builddep { 'python-lxml': }

但是我找不到任何关于从脚本安装模块以及如何包含/要求它的参考.在我看来,木偶文档仅指 从命令安装线人偶工具

But I can't find any reference about installing a module from the script and how to include/require it. Seems to me that the puppet docs refer only to installing from the command line puppet tool

我也尝试做类似的事情:

I also tried doing something like:

define build_dep($pkgname){
    exec {
    "builddepend_$pkgname":
    commmand => "sudo apt-get build-dep $pkgname";
    }
}
build_dep{
    "python-imaging":
    pkgname => "python-imaging";

    "python-lxml":
    pkgname => "python-lxml";
}

但是 puppet 退出时出现错误.还有:

But puppet exited with an error on this. And also:

exec{"install apt module":

    command => "puppet module install puppetlabs/apt"
}

class { 'apt':
        require => Exec["install apt module"]}
include apt

apt::builddep { 'python-imaging':
 }

但是得到 找不到声明的类 apt at..

有什么想法吗?方向?我知道我遗漏了一些明显的东西,但无法弄清楚.

any ideas? directions? I know I'm missing something obvious but can't figure this out.

如果我预安装(从命令行使用 puppet module install)apt:builddep 工作正常.但我需要 puppet 来处理模块下载和安装.其他一些变通方法也适用于基本用例,但无法回答我的主要问题.

If I pre-install (with puppet module install from the commandline) the apt:builddep works fine. But I need puppet to handle the module downloading and installation. Some of the other work arounds also work for the basic use case but won't answer my main question.

推荐答案

我也遇到了这个问题.诀窍是在 puppet 供应器运行之前使用 vagrant shell 命令下载模块.

I ran into this problem as well. The trick is to download the modules using a vagrant shell command before the puppet provisioner runs.

config.vm.provision :shell do |shell|
  shell.inline = "mkdir -p /etc/puppet/modules;
                  puppet module install puppetlabs/nodejs;
                  puppet module install puppetlabs/apache"
end

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "puppet/manifests"
  puppet.manifest_file = "site.pp"
end

这里的顺序很重要,因为 puppet 配置器还没有运行,文件夹/etc/puppet/modules 还不存在.

Order is important here, and since the puppet provisioner hasn't run the folder /etc/puppet/modules does not exist yet.

我决定像 alonisser 一样使用 puppet 模块工具安装模块而不是使用带有 vagrant puppet 配置器的模块文件夹的原因是因为我不想下载所有模块的依赖项我打算在我的源代码管理中使用和存储所有这些模块.运行这两个命令会产生 5 个依赖项,否则它们会占用我的 git 存储库中的空间.

The reason I decided, like alonisser, to install the modules using the puppet module tool instead of using a module folder with the vagrant puppet provisioner was because I didn't want to have to download all of the dependencies of the modules I was going to use and store all of those modules in my source control. Running these two commands results in 5 dependencies that would otherwise sit in my git repository taking up space.

这篇关于从清单脚本安装 puppet 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆