次の例は、Puppet マニフェスト内で zone リソースタイプを宣言することによって Oracle Solaris ゾーン構成を定義する 1 つの方法を示しています。
使用例 8 Puppet を使用した Oracle Solaris ゾーンの構成puppet describe コマンド (次の部分的な出力例に示されています) を実行することによって、最初に zone リソースタイプに対して宣言できるすべての属性のリストを表示します。
# puppet describe zone
zone
====
Manages Solaris zones.
Parameters
----------
- **archive**
The archive file containing an archived zone.
- **archived_zonename**
The archived zone to configure and install
- **brand**
The zone's brand type
- **clone**
Instead of installing the zone, clone it from another zone.
If the zone root resides on a zfs file system, a snapshot will be
used to create the clone; if it resides on a ufs filesystem, a copy of
the
zone will be used. The zone from which you clone must not be running.
- **config_profile**
Path to the config_profile to use to configure a solaris zone.
This is set when providing a sysconfig profile instead of running the
sysconfig SCI tool on first boot of the zone.
- **ensure**
The running state of the zone. The valid states directly reflect
the states that `zoneadm` provides. The states are linear,
in that a zone must be `configured`, then `installed`, and
only then can be `running`. Note also that `halt` is currently
used to stop zones.
Valid values are `absent`, `configured`, `installed`, `running`.
.
.
.
- **zonecfg_export**
Contains the zone configuration information. This can be passed in
in the form of a file generated by the zonecfg command, in the form
of a template, or a string.
- **zonepath**
The path to zone's file system.
Providers
---------
solaris
zonecfg_export 属性 (前の出力に示されています) を使用すると、zonecfg コマンドを使用してゾーン構成ファイルリソースを次のように作成できます。
# zonecfg -z testzone1
Use 'create' to begin configuring a new zone.
zonecfg:testzone> create
create: Using system default template 'SYSdefault'
zonecfg:testzone> export -f /tmp/zone.cfg
zonecfg:testzone> exit
root@master:~# cat /tmp/zone.cfg
create -b
set zonepath=/system/zones/%{zonename}
set autoboot=false
set autoshutdown=shutdown
set ip-type=exclusive
add anet
set linkname=net0
set lower-link=auto
set configure-allowed-address=true
set link-protection=mac-nospoof
set mac-address=auto
end
root@master:~# cp /tmp/zone.cfg /etc/puppet/modules/mycompany
作成したゾーンは、zone リソースタイプが適用されたときに構成可能になります。Puppet マニフェスト内で zone リソースタイプを次のように宣言します。
zone { 'systemazone':
zonecfg_export => 'puppet:///modules/mycompany/zone.conf',
ensure => 'running',
}
ここでは、ensure 属性の値が installed に設定されています。ensure の値は、ゾーンに対して受け入れ可能なステータス (installed および running) に一致しています。この例では、systemazone と呼ばれるゾーンがノード上に作成されています。
最後の手順として、ノードが自身に構成を適用したことを確認します。
# zoneadm list -cv ID NAME STATUS PATH BRAND IP 0 global running / solaris shared - systemazone running /system/zones/systemazone solaris excl
前のコマンドの出力は、非大域ゾーン systemazone が構成およびインストールされ、実行されていることを示しています。