Management of Solaris Zones
Jorge Schrauwen <sjorge@blackdot.be>
new
salt.modules.zoneadm, salt.modules.zonecfg
solaris
New in version 2017.7.0.
Below are some examples of how to use this state. Lets start with creating a zone and installing it.
omipkg1_configuration:
zone.present:
- name: omipkg1
- brand: ipkg
- zonepath: /zones/omipkg1
- properties:
- autoboot: true
- ip-type: exclusive
- cpu-shares: 50
- resources:
- attr:
- name: owner
- value: Jorge Schrauwen
- type: string
- attr:
- name: description
- value: OmniOS ipkg zone for testing
- type: string
- capped-memory:
- physical: 64M
omipkg1_installation:
zone.installed:
- name: omipkg1
- require:
- zone: omipkg1_configuration
omipkg1_running:
zone.booted:
- name: omipkg1
- require:
- zone: omipkg1_installation
A zone without network access is not very useful. We could update the zone.present state in the example above to add a network interface or we could use a separate state for this.
omipkg1_network:
zone.resource_present:
- name: omipkg1
- resource_type: net
- resource_selector_property: mac-addr
- resource_selector_value: "02:08:20:a2:a3:10"
- physical: znic1
- require:
- zone: omipkg1_configuration
Since this is a single tenant system having the owner attribute is pointless. Let's remove that attribute.
Note
The following state run the omipkg1_configuration state will add it again! If the entire configuration is managed it would be better to add resource_prune and optionally the resource_selector_property properties to the resource.
omipkg1_strip_owner:
zone.resource_present:
- name: omipkg1
- resource_type: attr
- resource_selector_property: name
- resource_selector_value: owner
- require:
- zone: omipkg1_configuration
Let's bump the zone's CPU shares a bit.
Note
The following state run the omipkg1_configuration state will set it to 50 again. Update the entire zone configuration is managed you should update it there instead.
omipkg1_more_cpu:
zone.property_present:
- name: omipkg1
- property: cpu-shares
- value: 100
Or we can remove the limit altogether!
Note
The following state run the omipkg1_configuration state will set it to 50 again. Update the entire zone configuration is managed you should set the property to None (nothing after the :) instead.
omipkg1_no_cpu:
zone.property_absent:
- name: omipkg1
- property: cpu-shares
Ensure a zone is absent
name of the zone
when true, uninstall instead of detaching the zone first.
Ensure zone is attached
name of the zone
force attach the zone
Ensure zone is booted
name of the zone
boot in single usermode
Ensure zone is detached
name of the zone
Export a zones configuration
name of the zone
path of file to export too.
replace the file if it exists
Ensure zone is halted
name of the zone
use shutdown instead of halt if true
Import a zones configuration
name of the zone
path of the configuration file to import
either import, install, or attach
do not create a ZFS file system
brand specific options to pass
Note
The mode argument can be set to import
, install
, or attach
.
import
: will only import the configuration
install
: will import and then try to install the zone
attach
: will import and then try to attach of the zone
omipkg1:
zone.import:
- path: /foo/bar/baz
Ensure zone is installed
name of the zone
do not create a ZFS file system
brand specific options to pass
Ensure a zone with certain properties and resources
name of the zone
brand of the zone
path of the zone
dict of properties
dict of resources
Note
If the zone does not exist it will not be installed.
You can use the `zone.installed`
state for this.
Note
fs: dir
net: mac-addr
device: match
rctl: name
attr: name
dataset: name
admin: user
Warning
Properties and resource will not be removed when they are absent from the state!
For properties, simple set them to `None`
.
For resources, add the `resource_prune`
property
and set it to `True`
. Also specify the
`resource_selector_property`
if the default is not
the one you want.
Ensure property is absent
name of the zone
name of property
Note
This does a zoneacfg clear call. So the property may be reset to a default value! Does has the side effect of always having to be called.
Ensure property has a certain value
name of the zone
name of property
value of property
Ensure resource is absent
name of the zone
type of resource
unique resource identifier
value for resource selection
Warning
Both resource_selector_property and resource_selector_value must be provided, some properties
like `name`
are already reserved by salt in there states.
Note
You can set both resource_selector_property and resource_selector_value to None for resources that do not require them.
Ensure resource exists with provided properties
name of the zone
type of resource
unique resource identifier
value for resource selection
resource properties
Warning
Both resource_selector_property and resource_selector_value must be
provided, some properties like name
are already reserved by salt in
states.
Note
You can set both resource_selector_property and resource_selector_value to None for resources that do not require them.
Ensure zone is uninstalled
name of the zone