salt.states.zone

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.

Bellow 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 seperate 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

name
: string
name of the zone
uninstall
: boolean
when true, uninstall instead of detaching the zone first.
salt.states.zone.attached(name, force=False)

Ensure zone is attached

name
: string
name of the zone
force
: boolean
force attach the zone
salt.states.zone.booted(name, single=False)

Ensure zone is booted

name
: string
name of the zone
single
: boolean
boot in single usermode
salt.states.zone.detached(name)

Ensure zone is detached

name
: string
name of the zone
salt.states.zone.export(name, path, replace=False)

Export a zones configuration

name
: string
name of the zone
path
: string
path of file to export too.
replace
: boolean
replace the file if it exists
salt.states.zone.halted(name, graceful=True)

Ensure zone is halted

name
: string
name of the zone
graceful
: boolean
use shutdown instead of halt if true
salt.states.zone.import(name, path, mode='import', nodataset=False, brand_opts=None)

Import a zones configuration

name
: string
name of the zone
path
: string
path of the configuration file to import
mode
: string
either import, install, or attach
nodataset
: boolean
do not create a ZFS file system
brand_opts
: boolean
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

salt.states.zone.installed(name, nodataset=False, brand_opts=None)

Ensure zone is installed

name
: string
name of the zone
nodataset
: boolean
do not create a ZFS file system
brand_opts
: boolean
brand specific options to pass
salt.states.zone.present(name, brand, zonepath, properties=None, resources=None)

Ensure a zone with certain properties and resouces

name
: string
name of the zone
brand
: string
brand of the zone
zonepath
: string
path of the zone
properties
: list of key-value pairs
dict of properties
resources
: list of key-value pairs
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

Default resource selectors:
  • 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.

salt.states.zone.property_absent(name, property)

Ensure property is absent

name
: string
name of the zone
property
: string
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.

salt.states.zone.property_present(name, property, value)

Ensure property has a certain value

name
: string
name of the zone
property
: string
name of property
value
: string
value of property
salt.states.zone.resource_absent(name, resource_type, resource_selector_property, resource_selector_value)

Ensure resource is absent

name
: string
name of the zone
resource_type
: string
type of resource
resource_selector_property
: string
unique resource identifier
resource_selector_value
: string
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.

salt.states.zone.resource_present(name, resource_type, resource_selector_property, resource_selector_value, **kwargs)

Ensure resource exists with provided properties

name
: string
name of the zone
resource_type
: string
type of resource
resource_selector_property
: string
unique resource identifier
resource_selector_value
: string
value for resource selection
**kwargs
: string|int|...
resource properties

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.uninstalled(name)

Ensure zone is uninstalled

name
: string
name of the zone