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.

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

namestring

name of the zone

uninstallboolean

when true, uninstall instead of detaching the zone first.

salt.states.zone.attached(name, force=False)

Ensure zone is attached

namestring

name of the zone

forceboolean

force attach the zone

salt.states.zone.booted(name, single=False)

Ensure zone is booted

namestring

name of the zone

singleboolean

boot in single usermode

salt.states.zone.detached(name)

Ensure zone is detached

namestring

name of the zone

salt.states.zone.export(name, path, replace=False)

Export a zones configuration

namestring

name of the zone

pathstring

path of file to export too.

replaceboolean

replace the file if it exists

salt.states.zone.halted(name, graceful=True)

Ensure zone is halted

namestring

name of the zone

gracefulboolean

use shutdown instead of halt if true

salt.states.zone.import_(name, path, mode='import', nodataset=False, brand_opts=None)

Import a zones configuration

namestring

name of the zone

pathstring

path of the configuration file to import

modestring

either import, install, or attach

nodatasetboolean

do not create a ZFS file system

brand_optsboolean

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
salt.states.zone.installed(name, nodataset=False, brand_opts=None)

Ensure zone is installed

namestring

name of the zone

nodatasetboolean

do not create a ZFS file system

brand_optsboolean

brand specific options to pass

salt.states.zone.present(name, brand, zonepath, properties=None, resources=None)

Ensure a zone with certain properties and resources

namestring

name of the zone

brandstring

brand of the zone

zonepathstring

path of the zone

propertieslist of key-value pairs

dict of properties

resourceslist 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

namestring

name of the zone

propertystring

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

namestring

name of the zone

propertystring

name of property

valuestring

value of property

salt.states.zone.resource_absent(name, resource_type, resource_selector_property, resource_selector_value)

Ensure resource is absent

namestring

name of the zone

resource_typestring

type of resource

resource_selector_propertystring

unique resource identifier

resource_selector_valuestring

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

namestring

name of the zone

resource_typestring

type of resource

resource_selector_propertystring

unique resource identifier

resource_selector_valuestring

value for resource selection

kwargsstring|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 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

namestring

name of the zone