Management of Solaris Zones
maintainer: | Jorge Schrauwen <sjorge@blackdot.be> |
---|---|
maturity: | new |
depends: | salt.modules.zoneadm, salt.modules.zonecfg |
platform: | 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
salt.states.zone.
absent
(name, uninstall=False)¶Ensure a zone is absent
salt.states.zone.
attached
(name, force=False)¶Ensure zone is attached
salt.states.zone.
booted
(name, single=False)¶Ensure zone is booted
salt.states.zone.
detached
(name)¶Ensure zone is detached
salt.states.zone.
export
(name, path, replace=False)¶Export a zones configuration
salt.states.zone.
halted
(name, graceful=True)¶Ensure zone is halted
salt.states.zone.
import_
(name, path, mode='import', nodataset=False, brand_opts=None)¶Import a zones configuration
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
salt.states.zone.
installed
(name, nodataset=False, brand_opts=None)¶Ensure zone is installed
salt.states.zone.
present
(name, brand, zonepath, properties=None, resources=None)¶Ensure a zone with certain properties and resources
Note
If the zone does not exist it will not be installed.
You can use the `zone.installed`
state for this.
Note
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.
salt.states.zone.
property_absent
(name, property)¶Ensure property is absent
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.
salt.states.zone.
property_present
(name, property, value)¶Ensure property has a certain value
salt.states.zone.
resource_absent
(name, resource_type, resource_selector_property, resource_selector_value)¶Ensure resource is absent
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.
salt.states.zone.
resource_present
(name, resource_type, resource_selector_property, resource_selector_value, **kwargs)¶Ensure resource exists with provided 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.
salt.states.zone.
uninstalled
(name)¶Ensure zone is uninstalled