当前位置:  开发笔记 > 后端 > 正文

如何从源本地构建和安装Puppet模块?

如何解决《如何从源本地构建和安装Puppet模块?》经验,为你挑选了1个好方法。

我发现了一个木偶模块,其作者只是添加了一些修改,否则我必须手动完成.

字面上发生在20个小时前.

我已将master分支下载到zip文件,将其解压缩到我的modules文件夹,并运行puppet module build --verbose /etc/puppet/modules/arioch-redis,但无济于事.

我明白这绝对不是正常行为,但我觉得这个问题值得关注.

从源代码中使用模块肯定有一个用例,特别是在快速移动或依赖快速反馈的项目中.

我已就此做了一些研究,请随意问一下,"你有没有看过X"的问题.

例如,我查看了https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#build-your-module,但它似乎主要是为了将模块上传到Forge,而不是从本地安装资源.

另外,我的尝试在" 构建您的模块 "部分失败了.

下面的所有三个似乎用"安装librarian-puppet"来回答这个问题,但考虑到我们可以编写自己的模块,librarian-puppet使用来自公共可用git存储库的源代码来使用简单的代码似乎很愚蠢.模块:

更改木偶模块源(我在寻找的答案,会发生什么情况的OP将会造成这个问题的答案私人回购协议.)

如何使用puppet模块安装从本地仓库安装puppet文件(我的借口:我不需要只使用该puppet module install工具.我也可以使用其他木偶工具.)

直接从克隆的回购中使用puppet模块(我的借口:答案似乎与此问题无关.)

从清单脚本安装puppet模块(我的借口:再次,我认为最适合该问题的最佳答案是"不要使用Puppet,找到解决方法."在这种情况下,解决方法是让Vagrant部分使用Shell Provisioning.)

如果这确实是重复或摘要,请在评论中说明,也许我可以解释一下.编辑欢迎!

我需要破解metadata.json内容吗?

我应该在某个地方克隆这个存储库并将其链接到我自己的临时Forge帐户,还是什么?

摘要:

我怎样才能获得该模块的最新版本,当它在其Git存储库中传递Travis时,但在Forge使其可用之前?



1> Peter Souter..:

从forge下载的Puppet模块仍然是文件夹,puppet模块命令只是解压缩它们并使用API​​下载依赖项.

因此,您的方法很接近,您只需要确保该文件夹具有正确的目录名称:

所以对于你的例子:

$ puppet module list
/Users/foo/.puppet/modules
??? fiddyspence-sysctl (v1.1.0)
??? puppetlabs-apt (v1.8.0)
??? puppetlabs-aws (v1.0.0)
??? puppetlabs-nodejs (v0.7.1)
??? puppetlabs-stdlib (v4.6.0)
$ cd /Users/foo/.puppet/modules
$ ll
total 0
drwxr-xr-x  15 foo  staff  510 Mar 17  2015 apt
drwxr-xr-x  18 foo  staff  612 Mar 26  2015 aws
drwxr-xr-x  14 foo  staff  476 Jan 22  2015 nodejs
drwxr-xr-x  17 foo  staff  578 Apr 15  2015 stdlib
drwxr-xr-x  12 foo  staff  408 Feb  9  2015 sysctl
$ wget https://github.com/arioch/puppet-redis/archive/master.zip
--2015-12-02 11:56:24--  https://github.com/arioch/puppet-redis/archive/master.zip
Resolving github.com... 192.30.252.130
Connecting to github.com|192.30.252.130|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/arioch/puppet-redis/zip/master [following]
--2015-12-02 11:56:24--  https://codeload.github.com/arioch/puppet-redis/zip/master
Resolving codeload.github.com... 192.30.252.144
Connecting to codeload.github.com|192.30.252.144|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 29509 (29K) [application/zip]
Saving to: 'master.zip'

master.zip                    100%[==================================================>]  28.82K  --.-KB/s   in 0.1s

2015-12-02 11:56:25 (257 KB/s) - 'master.zip' saved [29509/29509]

$ unzip master.zip
Archive:  master.zip
4fb33b960a09bfb459eff20ee112bfc9e0a1c096
   creating: puppet-redis-master/
  inflating: puppet-redis-master/.fixtures.yml
  inflating: puppet-redis-master/.gitignore
 extracting: puppet-redis-master/.puppet-lint.rc
  inflating: puppet-redis-master/.travis.yml
  inflating: puppet-redis-master/Gemfile
  inflating: puppet-redis-master/LICENSE
  inflating: puppet-redis-master/README.md
  inflating: puppet-redis-master/Rakefile
   creating: puppet-redis-master/manifests/
  inflating: puppet-redis-master/manifests/config.pp
  inflating: puppet-redis-master/manifests/init.pp
  inflating: puppet-redis-master/manifests/install.pp
  inflating: puppet-redis-master/manifests/params.pp
  inflating: puppet-redis-master/manifests/preinstall.pp
  inflating: puppet-redis-master/manifests/sentinel.pp
  inflating: puppet-redis-master/manifests/service.pp
  inflating: puppet-redis-master/metadata.json
   creating: puppet-redis-master/spec/
   creating: puppet-redis-master/spec/classes/
  inflating: puppet-redis-master/spec/classes/redis_sentinel_spec.rb
  inflating: puppet-redis-master/spec/classes/redis_spec.rb
 extracting: puppet-redis-master/spec/spec.opts
  inflating: puppet-redis-master/spec/spec_helper.rb
   creating: puppet-redis-master/templates/
  inflating: puppet-redis-master/templates/redis-sentinel.conf.erb
  inflating: puppet-redis-master/templates/redis-sentinel.init.erb
  inflating: puppet-redis-master/templates/redis.conf.erb
$ mv puppet-redis-master/ redis
$ ll
total 64
drwxr-xr-x  15 foo  staff    510 Mar 17  2015 apt
drwxr-xr-x  18 foo  staff    612 Mar 26  2015 aws
-rw-r--r--   1 foo  staff  29509 Dec  2 11:56 master.zip
drwxr-xr-x  14 foo  staff    476 Jan 22  2015 nodejs
drwxr-xr-x  14 foo  staff    476 Nov 30 15:10 redis
drwxr-xr-x  17 foo  staff    578 Apr 15  2015 stdlib
drwxr-xr-x  12 foo  staff    408 Feb  9  2015 sysctl

您会注意到它抱怨缺少依赖性.

$ puppet module list
Warning: Module 'puppetlabs-apt' (v1.8.0) fails to meet some dependencies:
  'arioch-redis' (v1.1.3) requires 'puppetlabs-apt' (>= 2.0.1 <3.0.0)
Warning: Missing dependency 'stahnma-epel':
  'arioch-redis' (v1.1.3) requires 'stahnma-epel' (>= 1.0.2 <2.0.0)
/Users/foo/.puppet/modules
??? arioch-redis (v1.1.3)
??? fiddyspence-sysctl (v1.1.0)
??? puppetlabs-apt (v1.8.0)  invalid
??? puppetlabs-aws (v1.0.0)
??? puppetlabs-nodejs (v0.7.1)
??? puppetlabs-stdlib (v4.6.0)

据我所知:没有办法使用Puppet的模块命令解决本地模块的依赖关系.

这就是图书管理员傀儡的来源:

$ cd redis/
$ librarian-puppet install --path ../. --verbose
[Librarian] Ruby Version: 2.1.2
[Librarian] Ruby Platform: x86_64-darwin14.0
[Librarian] Rubygems Version: 2.4.8
[Librarian] Librarian Version: 0.6.3
[Librarian] Librarian Adapter: puppet
[Librarian] Librarian Adapter Version: 2.2.1
[Librarian] Project: /Users/foo/.puppet/modules/redis
[Librarian] Specfile: Puppetfile
[Librarian] Lockfile: Puppetfile.lock
[Librarian] Git: /opt/boxen/homebrew/bin/git
[Librarian] Git Version: 2.4.3
[Librarian] Git Environment Variables:
[Librarian]   GIT_PS1_SHOWDIRTYSTATE=true
[Librarian]   GIT_PS1_SHOWSTASHSTATE=true
[Librarian]   GIT_PS1_SHOWUNTRACKEDFILES=true
[Librarian]   GIT_PS1_SHOWUPSTREAM=auto
[Librarian] Pre-Cached Sources:
[Librarian]   [:forge, "https://forgeapi.puppetlabs.com", {}]
[Librarian] Specfile /Users/foo/.puppet/modules/redis/Puppetfile not found, using defaults
[Librarian] Post-Cached Sources:
[Librarian]   [:forge, "https://forgeapi.puppetlabs.com", {}]
[Librarian] The specfile is unchanged: nothing to do.
[Librarian] Install: dependencies resolved
[Librarian] Installing puppetlabs-stdlib/4.9.0 
[Librarian] Installing puppetlabs-apt/2.2.0 
[Librarian] Installing stahnma-epel/1.2.0 
$ puppet module list
/Users/petersouter/.puppet/modules
??? arioch-redis (v1.1.3)
??? fiddyspence-sysctl (v1.1.0)
??? puppetlabs-apt (v2.2.0)
??? puppetlabs-aws (v1.0.0)
??? puppetlabs-nodejs (v0.7.1)
??? puppetlabs-stdlib (v4.9.0)
??? stahnma-epel (v1.2.0)

如果您不想使用puppet-librarian,您也可以手动更新这些模块:

$ puppet module install puppetlabs-apt -v 2.0.1 --force
Notice: Preparing to install into /Users/petersouter/.puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/Users/foo/.puppet/modules
??? puppetlabs-apt (v2.0.1)

$ puppet module install stahnma-epel -v 1.2.0 --force
Notice: Preparing to install into /Users/petersouter/.puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/Users/foo/.puppet/modules
??? stahnma-epel (v1.2.0)

推荐阅读
重庆制造漫画社
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有