未检测到 stdlib 模块

stdlib module is not detected

我有一个模块,据说需要 puppetlabs-stdlib

[vagrant@learn puppet]$ sudo /opt/puppetlabs/bin/puppet module list --tree --modulepath=/vagrant/puppet -v
Warning: Missing dependency 'puppetlabs-stdlib':
  'elk' (v0.1.0) requires 'puppetlabs-stdlib' (>= 1.0.0)
/vagrant/puppet
└─┬ elk (v0.1.0)
  └── UNMET DEPENDENCY puppetlabs-stdlib (>= 1.0.0)

我安装的模块如下:

[vagrant@learn puppet]$ sudo /opt/puppetlabs/bin/puppet module install puppetlabs-stdlib
Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Notice: Installing -- do not interrupt ...
/etc/puppetlabs/code/environments/production/modules
└── puppetlabs-stdlib (v6.1.0)

但是,缺少的依赖项仍然没有解决。如何让 Puppet 看到我安装的库?

命令

sudo /opt/puppetlabs/bin/puppet module list --tree --modulepath=/vagrant/puppet -v

报告 elk 模块对 puppetlabs-stdlib 的依赖性未得到满足,而您显示该模块将安装在 /etc/puppetlabs/code/environments/production/modules 中。这些事实是一致的。

puppet module list--modulepath 参数并不符合您的预期。如果您考虑到 Puppet's definition of the term:

,这可能会更清楚

The master service and the puppet apply command load most of their content from modules found in one or more directories. The list of directories where Puppet looks for modules is called the modulepath. The modulepath is set by the current node's environment.

The modulepath is an ordered list of directories, with earlier directories having priority over later ones. Use the system path separator character to separate the directories in the modulepath list. On *nix systems, use a colon (:); on Windows use a semi-colon (;).

您的 puppet module list 命令的 --modulepath 选项表示完整的模块路径,因此,在您的命令中它告诉 Puppet 仅考虑 /vagrant/puppet 中的模块。关于该模块路径,确实未满足 stdlib 依赖关系。

此替代方案应显示满足依赖性:

sudo /opt/puppetlabs/bin/puppet module list --tree \
  --modulepath=/etc/puppetlabs/code/environments/production/modules:/vagrant/puppet -v

这两个结果在 Puppet 运行时的意义取决于 Puppet 用于目录构建的模块路径。如果您完全不使用 --modulepath 选项,那么您将获得与 Puppet 当前配置和默认环境相关的结果,这可能与您的实际使用场景更相关,也可能不相关。

您没有引用相同的模块路径。

首先,您根据 --modulepath 语句列出 /vagrant/puppet 中的模块。

安装时,您没有指定模块路径,因此根据安装的标准: Notice: Preparing to install into /etc/puppetlabs/code/environments/production/modules

因此您必须将 stdlib 安装指向相同的路径:puppet module --modulepath=/vagrant/puppet install puppetlabs-stdlib,或者将客户端的模块路径更新为 运行 关闭默认值,/etc/puppetlabs/code/environments/production/modules