Volume

volume

Allows you to create, update or remove a volume from a Ionos datacenter.

Example Syntax


name: Create volumes
ionoscloudsdk.ionoscloud.volume:
  datacenter: 'AnsibleAutoTestCompute'
  name: 'AnsibleAutoTestCompute %02d'
  disk_type: SSD Premium
  image: 'centos:7'
  image_password: '{{ lookup('ansible.builtin.password', '/dev/null chars=ascii_letters,digits') }}'
  count: 2
  size: 20
  availability_zone: AUTO
  cpu_hot_plug: false
  ram_hot_plug: true
  nic_hot_plug: true
  nic_hot_unplug: true
  disc_virtio_hot_plug: true
  disc_virtio_hot_unplug: true
  wait_timeout: 600
  wait: true
  state: present
register: volume_create_response


name: Update no change
ionoscloudsdk.ionoscloud.volume:
  datacenter: 'AnsibleAutoTestCompute'
  instance_ids:
  - 'AnsibleAutoTestCompute 01'
  disk_type: SSD Premium
  size: 20
  availability_zone: AUTO
  image: 01abcc20-a6b9-11ed-9e9f-e60bb43016ef
  licence_type: LINUX
  ram_hot_plug: true
  nic_hot_plug: true
  nic_hot_unplug: true
  disc_virtio_hot_plug: true
  disc_virtio_hot_unplug: true
  allow_replace: false
  wait_timeout: 600
  wait: true
  state: update
register: volume_create_response_nochange


name: Delete volumes
ionoscloudsdk.ionoscloud.volume:
  datacenter: 'AnsibleAutoTestCompute'
  instance_ids:
  - 'AnsibleAutoTestCompute modified'
  - 'AnsibleAutoTestCompute 02'
  wait_timeout: 600
  state: absent

Returned object

{
    "changed": true,
    "failed": false,
    "volumes": [
        {
            "href": "https://api.ionos.com/cloudapi/v6/datacenters/ea545f2e-4c15-4be7-8fb8-867fb6e9d330/volumes/9be90788-1b11-4d1b-bfb3-857f0c7bd5a3",
            "id": "9be90788-1b11-4d1b-bfb3-857f0c7bd5a3",
            "metadata": {
                "created_by": "<USER_EMAIL>",
                "created_by_user_id": "<USER_ID>",
                "created_date": "2023-05-29T09:43:18+00:00",
                "etag": "1e8b91b7c574e42452b1628408959166",
                "last_modified_by": "<USER_EMAIL>",
                "last_modified_by_user_id": "<USER_ID>",
                "last_modified_date": "2023-05-29T09:43:18+00:00",
                "state": "BUSY"
            },
            "properties": {
                "availability_zone": null,
                "backupunit_id": null,
                "boot_order": "AUTO",
                "boot_server": null,
                "bus": "VIRTIO",
                "cpu_hot_plug": false,
                "device_number": null,
                "disc_virtio_hot_plug": false,
                "disc_virtio_hot_unplug": false,
                "image": null,
                "image_alias": null,
                "image_password": null,
                "licence_type": "OTHER",
                "name": "AnsibleAutoTestCompute-data",
                "nic_hot_plug": false,
                "nic_hot_unplug": false,
                "pci_slot": null,
                "ram_hot_plug": false,
                "size": 20.0,
                "ssh_keys": [],
                "type": "HDD",
                "user_data": null
            },
            "type": "volume"
        }
    ],
    "action": "create",
    "instance_ids": [
        "9be90788-1b11-4d1b-bfb3-857f0c7bd5a3"
    ]
}

For more examples please check out the tests here.

NOTE: If you are using a versions 7.0.0 and up: modules can replace resources if certain set parameters differ from the results found in the API!

Parameters that can trigger a resource replacement:

  • size

  • disk_type

  • availability_zone

  • licence_type

  • user_data (Might trigger replace just by being set as this parameter is retrieved from the API as the image ID, so when using an alias it will always cause a resource replacement!)

  • image (Might trigger replace just by being set as this parameter is retrieved from the API as the image ID, so when using an alias it will always cause a resource replacement!)

  • image_password (Will trigger replace just by being set as this parameter cannot be retrieved from the api to check for changes!)

  • ssh_keys (Will trigger replace just by being set as this parameter cannot be retrieved from the api to check for changes!)

  • backupunit (Will trigger replace just by being set as this parameter cannot be retrieved from the api to check for changes!)

state: present

  
name: Create volumes
ionoscloudsdk.ionoscloud.volume:
  datacenter: 'AnsibleAutoTestCompute'
  name: 'AnsibleAutoTestCompute %02d'
  disk_type: SSD Premium
  image: 'centos:7'
  image_password: '{{ lookup('ansible.builtin.password', '/dev/null chars=ascii_letters,digits') }}'
  count: 2
  size: 20
  availability_zone: AUTO
  cpu_hot_plug: false
  ram_hot_plug: true
  nic_hot_plug: true
  nic_hot_unplug: true
  disc_virtio_hot_plug: true
  disc_virtio_hot_unplug: true
  wait_timeout: 600
  wait: true
  state: present
register: volume_create_response

Available parameters for state present:

NameRequiredDescription

datacenter str

True

The datacenter in which to create the volumes.

server str

False

The server to which to attach the volume.

name str

True

The name of the resource.

size int

False

The size of the volume in GB.

bus str

False

The bus type for this volume; default is VIRTIO. Default: VIRTIO Options: ['VIRTIO', 'IDE', 'UNKNOWN']

image str

False

Image or snapshot ID to be used as template for this volume.

image_password str

False

Initial password to be set for installed OS. Works with public images only. Not modifiable, forbidden in update requests. Password rules allows all characters from a-z, A-Z, 0-9.

ssh_keys list

False

Public SSH keys are set on the image as authorized keys for appropriate SSH login to the instance using the corresponding private key. This field may only be set in creation requests. When reading, it always returns null. SSH keys are only supported if a public Linux image is used for the volume creation.

disk_type str

False

The disk type of the volume. Options: ['HDD', 'SSD', 'SSD Premium', 'SSD Standard']

licence_type str

False

OS type for this volume. Options: ['UNKNOWN', 'WINDOWS', 'WINDOWS2016', 'WINDOWS2022', 'RHEL', 'LINUX', 'OTHER']

availability_zone str

False

The availability zone in which the volume should be provisioned. The storage volume will be provisioned on as few physical storage devices as possible, but this cannot be guaranteed upfront. This is uavailable for DAS (Direct Attached Storage), and subject to availability for SSD. Options: ['AUTO', 'ZONE_1', 'ZONE_2', 'ZONE_3']

count int

False

The number of volumes you wish to create. Default: 1

backupunit str

False

The ID of the backup unit that the user has access to. The property is immutable and is only allowed to be set on creation of a new a volume. It is mandatory to provide either 'public image' or 'imageAlias' in conjunction with this property.

user_data str

False

The cloud-init configuration for the volume as base64 encoded string. The property is immutable and is only allowed to be set on creation of a new a volume. It is mandatory to provide either 'public image' or 'imageAlias' that has cloud-init compatibility in conjunction with this property.

cpu_hot_plug bool

False

Hot-plug capable CPU (no reboot required).

ram_hot_plug bool

False

Hot-plug capable RAM (no reboot required).

nic_hot_plug bool

False

Hot-plug capable NIC (no reboot required).

nic_hot_unplug bool

False

Hot-unplug capable NIC (no reboot required).

disc_virtio_hot_plug bool

False

Hot-plug capable Virt-IO drive (no reboot required).

disc_virtio_hot_unplug bool

False

Hot-unplug capable Virt-IO drive (no reboot required). Not supported with Windows VMs.

allow_replace bool

False

Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead Default: False

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

state: absent

  
name: Delete volumes
ionoscloudsdk.ionoscloud.volume:
  datacenter: 'AnsibleAutoTestCompute'
  instance_ids:
  - 'AnsibleAutoTestCompute modified'
  - 'AnsibleAutoTestCompute 02'
  wait_timeout: 600
  state: absent

Available parameters for state absent:

NameRequiredDescription

datacenter str

True

The datacenter in which to create the volumes.

name str

False

The name of the resource.

instance_ids list

False

list of instance ids or names. Should only contain one ID if renaming in update state Default:

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

state: update

  
name: Update no change
ionoscloudsdk.ionoscloud.volume:
  datacenter: 'AnsibleAutoTestCompute'
  instance_ids:
  - 'AnsibleAutoTestCompute 01'
  disk_type: SSD Premium
  size: 20
  availability_zone: AUTO
  image: 01abcc20-a6b9-11ed-9e9f-e60bb43016ef
  licence_type: LINUX
  ram_hot_plug: true
  nic_hot_plug: true
  nic_hot_unplug: true
  disc_virtio_hot_plug: true
  disc_virtio_hot_unplug: true
  allow_replace: false
  wait_timeout: 600
  wait: true
  state: update
register: volume_create_response_nochange

Available parameters for state update:

NameRequiredDescription

datacenter str

True

The datacenter in which to create the volumes.

name str

False

The name of the resource.

size int

False

The size of the volume in GB.

bus str

False

The bus type for this volume; default is VIRTIO. Default: VIRTIO Options: ['VIRTIO', 'IDE', 'UNKNOWN']

availability_zone str

False

The availability zone in which the volume should be provisioned. The storage volume will be provisioned on as few physical storage devices as possible, but this cannot be guaranteed upfront. This is uavailable for DAS (Direct Attached Storage), and subject to availability for SSD. Options: ['AUTO', 'ZONE_1', 'ZONE_2', 'ZONE_3']

instance_ids list

False

list of instance ids or names. Should only contain one ID if renaming in update state Default:

cpu_hot_plug bool

False

Hot-plug capable CPU (no reboot required).

ram_hot_plug bool

False

Hot-plug capable RAM (no reboot required).

nic_hot_plug bool

False

Hot-plug capable NIC (no reboot required).

nic_hot_unplug bool

False

Hot-unplug capable NIC (no reboot required).

disc_virtio_hot_plug bool

False

Hot-plug capable Virt-IO drive (no reboot required).

disc_virtio_hot_unplug bool

False

Hot-unplug capable Virt-IO drive (no reboot required). Not supported with Windows VMs.

allow_replace bool

False

Boolean indicating if the resource should be recreated when the state cannot be reached in another way. This may be used to prevent resources from being deleted from specifying a different value to an immutable property. An error will be thrown instead Default: False

api_url str

False

The Ionos API base URL.

certificate_fingerprint str

False

The Ionos API certificate fingerprint.

username str

False

The Ionos username. Overrides the IONOS_USERNAME environment variable.

password str

False

The Ionos password. Overrides the IONOS_PASSWORD environment variable.

token str

False

The Ionos token. Overrides the IONOS_TOKEN environment variable.

wait bool

False

Wait for the resource to be created before returning. Default: True Options: [True, False]

wait_timeout int

False

How long before wait gives up, in seconds. Default: 600

state str

False

Indicate desired state of the resource. Default: present Options: ['present', 'absent', 'update']

Last updated