次の例は、マニフェスト内で Puppet package リソースタイプを宣言することによって新しい IPS ソフトウェアパッケージ (nmap) を追加する方法を示しています。
使用例 4 Puppet を使用したパッケージングの構成最初に、インストールする予定のパッケージがすでにインストールされているかどうかを判定します。
$ pkg info nmap pkg: info: no packages matching the following patterns you specified are installed on the system. Try specifying -r to query remotely:
パッケージがインストールされているかどうかをリモートでチェックする場合は、–r オプションを次のように使用します。
# pkg info -r nmap
Name: diagnostic/nmap
Summary: Network exploration tool and security / port scanner.
Description: Nmap is useful for inventorying the network, managing service
upgrade schedules, and monitoring host or service uptime.
Category: System/Administration and Configuration
State: Not installed
Publisher: solaris
Version: 6.25
Build Release: 5.11
Branch: 0.175.3.0.0.30.0
Packaging Date: Fri Aug 21 16:46:42 2015
Size: 19.07 MB
FMRI: pkg://solaris/diagnostic/nmap@6.25,5.11-0.175.3.0.0.30.0:20150821T164642Z
次に、puppet describe コマンド (次の部分的な出力例に示されています) を使用して、package リソースタイプに対して宣言する適切な属性をチェックします。
# puppet describe package
package
=======
Manage packages. There is a basic dichotomy in package
support right now: Some package types (e.g., yum and apt) can
retrieve their own package files, while others (e.g., rpm and sun)
cannot. For those package formats that cannot retrieve their own files,
you can use the `source` parameter to point to the correct file.
Puppet will automatically guess the packaging format that you are
using based on the platform you are on, but you can override it
using the `provider` parameter; each provider defines what it
requires in order to function, and you must meet those requirements
to use a given provider.
**Autorequires:** If Puppet is managing the files specified as a
package's `adminfile`, `responsefile`, or `source`, the package
resource will autorequire those files.
Parameters
----------
- **adminfile**
A file containing package defaults for installing packages.
This is currently only used on Solaris. The value will be
validated according to system rules, which in the case of
Solaris means that it should either be a fully qualified path
or it should be in `/var/sadm/install/admin`.
- **allow_virtual**
Specifies if virtual package names are allowed for install and
uninstall.
Valid values are `true`, `false`, `yes`, `no`.
Requires features virtual_packages.
- **allowcdrom**
Tells apt to allow cdrom sources in the sources.list file.
Normally apt will bail if you try this.
Valid values are `true`, `false`.
- **category**
A read-only parameter set by the package.
- **configfiles**
Whether configfiles should be kept or replaced. Most packages
types do not support this parameter. Defaults to `keep`.
Valid values are `keep`, `replace`.
- **description**
A read-only parameter set by the package.
- **ensure**
What state the package should be in. On packaging systems that can
retrieve new packages on their own, you can choose which package to
retrieve by specifying a version number or `latest` as the ensure
value. On packaging systems that manage configuration files separately
from "normal" system files, you can uninstall config files by
specifying `purged` as the ensure value. This defaults to `installed`.
Valid values are `present` (also called `installed`), `absent`,
`purged`, `held`, `latest`. Values can match `/./`.
.
.
.
そのあと、マスター上の Puppet マニフェスト内でリソースタイプを次のように宣言します。
package { 'nmap':
ensure => 'present',
}
前の例では、リソース定義のタイトルが nmap (インストールされるパッケージ) に設定され、ensure 属性の値が present に設定されています。これは、そのパッケージがインストールに使用可能かどうかをチェックします。
この構成は、次のように確認されます。
# pkg info nmap
Name: diagnostic/nmap
Summary: Network exploration tool and security / port scanner.
Description: Nmap is useful for inventorying the network, managing service
upgrade schedules, and monitoring host or service uptime.
Category: System/Administration and Configuration
State: Installed
Publisher: solaris
Version: 6.25
Build Release: 5.11
Branch: 0.175.3.0.0.30.0
Packaging Date: Fri Aug 21 16:46:42 2015
Size: 19.07 MB
FMRI: pkg://solaris/diagnostic/nmap@6.25,5.11-0.175.3.0.0.30.0:20150821T164642Z
前のコマンドの出力は、nmap パッケージが現在ノードにインストールされていることを示しています。このパッケージは、Puppet エージェントが実行されたときにインストールされます。または、構成の変更を手動で適用するために、ノード上で puppet agent –t コマンドを実行できます。
nmap パッケージをアンインストールしても、Puppet はそのパッケージをノードに再インストールすることによって、指定された構成を適用します。