如何使用 Puppetfile 在独立模式下配置服务器

How use Puppetfile to configure server in standalone mode

我正在创建人偶配置结构

puppet
│   ├── data
│   │   └── common.yaml
│   ├── hiera.yaml
│   ├── manifests
│   │   └── site.pp
│   ├── modules
│   │   ├── accessories
│   │   │   └── manifests
│   │   │       └── init.pp
│   │   ├── nginx
│   │   │   ├── manifests
│   │   │   │   ├── config.pp
│   │   │   │   ├── init.pp
│   │   │   │   └── install.pp
│   │   │   └── templates
│   │   │       └── vhost_site.erb
│   │   ├── php
│   │   │   ├── manifests
│   │   │   │   ├── config.pp
│   │   │   │   ├── init.pp
│   │   │   │   └── install.pp
│   │   │   └── templates
│   │   │       ├── php.ini.erb
│   │   │       └── www.conf.erb
│   │   └── site
│   │       └── manifests
│   │           ├── database.pp
│   │           ├── init.pp
│   │           └── webserver.pp
│   └── Puppetfile

现在我只有一台服务器,所以我有时会通过运行来手动更新它:

sudo puppet apply --hiera_config=hiera.yaml --modulepath=./modules manifests/site.pp

此刻我需要使用一些外部模块,例如我在下一行中添加了 Puppetfile。

forge "http://forge.puppetlabs.com"

mod 'puppetlabs-mysql', '3.10.0'

...当然没有用。 我试图在 'apply' (Configuration Reference) 的命令设置中找到配置它的东西,但没有成功。

使用 Puppetfile 在独立模式下自动配置 Puppet 是真的吗?还是只有 'puppet module install' 才有可能???

Puppet 文件不会被 Puppet 服务器或客户端代码解释或读取。他们在那里帮助其他工具有效地部署适当的人偶模块。

在您的情况下,为了利用您编写的 Puppetfile,您需要安装和配置 r10k。 HERE are the basics from the Puppet Enterprise documentation. HERE 是另一个很棒的资源,r10k GitHub 页面。

安装和配置后,r10k 将读取您的 Puppetfile 并下载+安装定义的条目。在您的情况下,它将安装 puppetlabs-mysql3.10.0 版本。这将安装到您的 modules 目录中,然后您可以执行 puppet 代理 运行 并利用新安装的模块。

总而言之,客户端不使用 Puppetfile,代码部署软件 (r10k) 使用它们来下载和构建适当的模块,供 Puppet 服务器或代理使用。您的选择是配置 r10k 以提供 Puppetfile 中定义的模块,或者手动下载模块并消除对 Puppetfile 的需求。