gpt4 book ai didi

build - 如何从源代码本地构建和安装 Puppet 模块?

转载 作者:行者123 更新时间:2023-12-04 23:42:14 25 4
gpt4 key购买 nike

我找到了一个 puppet 模块,它的作者只是添加了一堆修改,否则我必须自己手动进行。

这实际上发生在 20 小时前。

我已将主分支下载到一个 zip 文件,将其解压缩到我的模块文件夹,然后运行 ​​puppet module build --verbose /etc/puppet/modules/arioch-redis ,无济于事。

我知道这绝对不是正常行为,但我觉得这个问题值得关注。

绝对有使用源代码模块的用例,特别是在快速移动或依赖快速反馈的项目中。

我对此进行了一些研究,请随时在评论中提出“你看过 X”的问题。

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

另外,我的尝试在“Build Your Module”部分失败了。

以下所有三个似乎都用“安装图书馆员- puppet ”回答了这个问题,但鉴于我们可以编写自己的模块,不得不使用 librarian-puppet 似乎很愚蠢。使用来自公开可用的 git 存储库的源代码来使用一个简单的模块:

Changing puppet module source (我正在寻找 OP 在该答案中创建私有(private) repo 之后会发生什么的答案。)

How to install a puppet file from a local repo with puppet module install (我的借口:我不需要只使用 puppet module install 工具。我也可以使用其他 puppet 工具。)

Using puppet module straight from a cloned repo (我的借口:答案似乎与这个问题无关。)

Installing a puppet module from a manifest script (我的借口:再一次,我认为最适合该问题的最佳答案是“不要为此使用 Puppet,找到解决方法。”在这种情况下,解决方法是让 Vagrant 部分使用 Shell Provisioning。)

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

我需要破解 metadata.json内容?

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

概括:

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

最佳答案

从 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 的模块命令解决本地模块的依赖关系。

这就是图书馆员 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 <https://forgeapi.puppetlabs.com>
[Librarian] Installing puppetlabs-apt/2.2.0 <https://forgeapi.puppetlabs.com>
[Librarian] Installing stahnma-epel/1.2.0 <https://forgeapi.puppetlabs.com>
$ 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)

关于build - 如何从源代码本地构建和安装 Puppet 模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34035364/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com