我正在使用puppet来配置一个vagrant(基于ubuntu的)虚拟机.在我的脚本中,我需要:
sudo apt-get build-dep python-lxml
我知道我可以安装apt puppet模块,所以我可以使用:
apt::builddep { 'python-lxml': }
但我找不到任何关于从脚本安装模块以及如何包含/要求它的参考.在我看来,木偶文档仅指从命令行木偶工具安装
我也尝试过这样的事情:
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";
}
但是傀儡退出了这个错误.并且:
exec{"install apt module":
    command => "puppet module install puppetlabs/apt"
}
class { 'apt':
        require => Exec["install apt module"]}
include apt
apt::builddep { 'python-imaging':
 }
但得到了 could not find declared class apt at..
有任何想法吗?方向?我知道我错过了一些明显但却无法解决的问题.
编辑:如果我预先安装(puppet module install从命令行),apt:builddep工作正常.但我需要木偶来处理模块下载和安装.其他一些工作也适用于基本用例,但不会回答我的主要问题.
bra*_*con 63
我也遇到了这个问题.诀窍是在puppet provisioner运行之前使用vagrant shell命令下载模块.
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
订单在这里很重要,并且由于木偶供应商没有运行文件夹/ etc/puppet/modules还不存在.
我决定像alonisser一样使用puppet模块工具安装模块而不是使用带有vagrant puppet provisioner的模块文件夹的原因是因为我不想下载我要去的模块的所有依赖项在我的源代码管理中使用和存储所有这些模块.运行这两个命令会导致5个依赖项,否则这些依赖项会占用我的git存储库占用空间.
wta*_*com 14
这是我做的puppet module install命令最多运行一次:
$script = <<EOF
mkdir -p /etc/puppet/modules
(puppet module list | grep puppetlabs-mysql) ||
   puppet module install -v 2.1.0 puppetlabs/mysql
EOF
Vagrant::Config.run do |config|
   config.vm.provision :shell, :inline => $script
我使用类似于@brain_bacon的方法 - 我的额外复杂性是除了预装的模块,如puppetlabs/nodejs,我需要相对于我的Vagrantfile的本地模块.我不想将预先打包的模块作为我的存储库的一部分进行检查,也不想使用git子模块,因为@Igor Popov指出了这些问题.
最后,我选择的解决方案是使用shell脚本下载模块,但强制它们进入Vagrant VM和主机之间的共享目录,并使用.gitignore来避免该路径受源代码控制.
要清楚,有了这棵树:
jcmendez$ tree
.
??? README.md
??? Vagrantfile
??? files
??? puppet
?   ??? manifests
?   ?   ??? init.pp
?   ??? modules
?       ??? misc
?       ?   ??? manifests
?       ?       ??? init.pp
?       ??? mysql
   ...
?       ??? wordpress
?           ??? files
?           ?   ??? wordpress-db.sql
?           ?   ??? wp-config.php
?           ?   ??? wp-tests-config.php
?           ??? manifests
?               ??? init.pp
??? wordpress
在.gitignore我补充说
  /puppet/modules/mysql
上 Vagrantfile 
  config.vm.provision :shell do |shell|
    shell.inline = "puppet module install puppetlabs/mysql --force --modulepath '/vagrant/puppet/modules'"
  end
  config.vm.provision :puppet do |puppet|
    puppet.manifests_path = 'puppet/manifests'
    puppet.module_path = 'puppet/modules'
    puppet.manifest_file  = "init.pp"
    puppet.options="--verbose --debug"
  end
| 归档时间: | 
 | 
| 查看次数: | 22466 次 | 
| 最近记录: |