gcore.cloud.volume (1.0.1) — module

Manages volumes

Authors: GCore (@GCore)

Install collection

Install with ansible-galaxy collection install gcore.cloud:==1.0.1


Add to requirements.yml

  collections:
    - name: gcore.cloud
      version: 1.0.1

Description

Create/update/delete or attach/detach or retype/revert or extend volume

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new empty volume
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: create
    source: new-volume
    type_name: standard
    name: test-volume
    size: 2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new volume from image
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: create
    source: image
    type_name: standard
    image_id: "{{ image_id }}"
    name: test-volume
    size: 5
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a new volume from snapshot
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: create
    source: snapshot
    type_name: standard
    snapshot_id: "{{ snapshot_id }}"
    name: test-volume
    size: 5
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Extend existing volume
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: extend
    volume_id: "{{ volume_id }}"
    size: 20
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Attach existing volume to instance
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: attach
    volume_id: "{{ volume_id }}"
    instance_id: "{{ instance_id }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Detach existing volume from instance
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: detach
    volume_id: "{{ volume_id }}"
    instance_id: "{{ instance_id }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update existing volume's name
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: update
    volume_id: "{{ volume_id }}"
    name: new-volume-name
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Retype existing volume
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: retype
    volume_id: "{{ volume_id }}"
    volume_type: "{{ volume_type }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Revert existing volume
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: revert
    volume_id: "{{ volume_id }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete existing volume
  gcore.cloud.volume:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: delete
    volume_id: "{{ volume_id }}"

Inputs

    
name:
    description:
    - Volume name
    - Required if I(command) is create
    type: str

size:
    description:
    - Volume size. Must be positive integer
    - Used if I(command) one of create
    type: int

source:
    choices:
    - image
    - snapshot
    - new-volume
    description:
    - Source of new volume
    - Required if I(command) is create
    type: str

api_key:
    description:
    - GCore API auth key
    - Can be passed as I(CLOUD_API_KEY) environment variable.
    type: str

command:
    choices:
    - create
    - update
    - delete
    - attach
    - detach
    - extend
    - retype
    - revert
    description:
    - Operation to perform.
    required: true
    type: str

api_host:
    default: https://api.gcore.com/cloud
    description:
    - GCore API base host
    - Can be passed as I(CLOUD_API_HOST) environment variable.
    type: str

image_id:
    description:
    - Image ID
    - Required if I(command) is create and I(source) is image
    type: str

metadata:
    description:
    - Create one or more metadata items for a volume
    - Used if I(command) one of create
    type: dict

region_id:
    description:
    - GCore API region ID
    - Required if I(region_name) is not passed
    - Can be passed as I(CLOUD_REGION_ID) environment variable.
    type: int

snapshots:
    description:
    - Comma separated list of snapshot IDs to be deleted with the volume
    - Used if I(command) is delete
    type: str

type_name:
    choices:
    - standard
    - ssd_hiiops
    - cold
    - ultra
    - ssd_local
    - ssd_lowlatency
    description:
    - One of 'standard', 'ssd_hiiops', 'cold', 'ultra', 'ssd_lowlatency'.
    - If not specified for - source 'snapshot', volume type will be derived from the snapshot
      volume.
    - Otherwise defaults to standard.
    - Required if I(command) is create
    type: str

volume_id:
    description:
    - Volume ID
    type: str

project_id:
    description:
    - GCore API project ID
    - Required if I(project_name) is not passed
    - Can be passed as I(CLOUD_PROJECT_ID) environment variable.
    type: int

api_timeout:
    default: 30
    description:
    - Timeout in seconds to polling GCore API
    type: int

instance_id:
    description:
    - Instance ID attach to
    - Required if I(command) is attach
    type: str

region_name:
    description:
    - GCore API region name
    - Required if I(region_id) is not passed
    - Can be passed as I(CLOUD_REGION_NAME) environment variable.
    type: str

snapshot_id:
    description:
    - Snapshot ID
    - Required if I(command) is create
    type: str

volume_type:
    choices:
    - standard
    - ssd_hiiops
    description:
    - Volume type. Must be one of standard or ssd_hiiops
    - Required if I(command) is retype
    type: str

project_name:
    description:
    - GCore API project name
    - Required if I(project_id) is not passed
    - Can be passed as I(CLOUD_PROJECT_NAME) environment variable.
    type: str

attachment_tag:
    description:
    - Block device attachment tag (exposed in the metadata).
    - Only used in conjunction with instance_id_to_attach_to.
    - Used if I(command) is create
    type: str

lifecycle_policy_ids:
    description:
    - Lifecycle policy ID list
    - Used if I(command) is create
    elements: int
    type: list

instance_id_to_attach_to:
    description:
    - VM instance_id to attach newly-created volume to
    - Used if I(command) is create
    type: str

Outputs

volume:
  contains:
    attachments:
      description: Attachment list
      returned: if available
      sample:
      - attached_at: '2019-07-26T14:22:03.000000'
        attachment_id: f2ed59d9-8068-400c-be4b-c4501ef6f33c
        device: /dev/vda
        instance_name: '123'
        server_id: 8dc30d49-bb34-4920-9bbd-03a2587ec0ad
        volume_id: 67baa7d1-08ea-4fc5-bef2-6b2465b7d227
      type: list
    bootable:
      description: Bootable boolean flag
      returned: if available
      sample: false
      type: bool
    created_at:
      description: Datetime when the volume was created
      returned: always
      sample: 2019-05-29T05:32:41+0000
      type: str
    creator_task_id:
      description: Task that created this entity
      returned: if available
      sample: d74c2bb9-cea7-4b23-a009-2f13518ae66d
      type: str
    device:
      description: Device name
      returned: if available
      sample: test
      type: str
    id:
      description: Volume ID
      returned: always
      sample: 726ecfcc-7fd0-4e30-a86e-7892524aa483
      type: str
    is_root_volume:
      description: Root volume flag
      returned: if available
      sample: false
      type: bool
    limiter_stats:
      description: Snapshots of this volume
      returned: if available
      sample:
        MBps_base_limit: 10
        MBps_burst_limit: 100
        iops_base_limit: 12
        iops_burst_limit: 120
      type: dict
    metadata:
      description: Metadata
      returned: if available
      sample:
        attached_mode: rw
        task_id: d74c2bb9-cea7-4b23-a009-2f13518ae66d
      type: dict
    metadata_detailed:
      description: Volume metadata
      returned: if available
      sample:
      - key: attached_mode
        read_only: true
        value: rw
      type: list
    name:
      description: Volume name
      returned: always
      sample: 123
      type: str
    project_id:
      description: Project ID
      returned: always
      sample: 1
      type: int
    region:
      description: Region name
      returned: always
      sample: Luxembourg 1
      type: str
    region_id:
      description: Region ID
      returned: always
      sample: 1
      type: int
    size:
      description: Volume size, GiB
      returned: always
      sample: 2
      type: int
    snapshot_ids:
      description: Snapshots of this volume
      returned: if available
      sample:
      - 907a87b0-7b63-4fd5-beb3-5ab4ba445c93
      type: list
    status:
      description: Volume status
      returned: always
      sample: available
      type: str
    task_id:
      description: Active task. If None, action has been performed immediately in
        the request itself
      returned: present
      sample: 907a87b0-7b63-4fd5-beb3-5ab4ba445c93
      type: str
    updated_at:
      description: Datetime when the volume was last updated
      returned: always
      sample: 2019-05-29T05:39:20+0000
      type: str
    volume_image_metadata:
      description: Image information for volumes that were created from image
      returned: if available
      sample:
        checksum: ba3cd24377dde5dfdd58728894004abb
        container_format: bare
        disk_format: raw
        image_id: 723037e2-ec6d-47eb-92de-6276c8907839
        image_name: cirros-gcloud
        min_disk: '1'
        min_ram: '0'
        owner_specified.openstack.md5: ba3cd24377dde5dfdd58728894004abb
        owner_specified.openstack.object: images/cirros-gcloud
        owner_specified.openstack.sha256: 87ddf8eea6504b5eb849e418a568c4985d3cea59b5a5d069e1dc644de676b4ec
        size: '46137344'
      type: dict
    volume_type:
      description: Volume type
      returned: always
      sample: standard
      type: str
  description:
  - Response depends of I(command).
  - Resource dictionary.
  returned: always
  type: complex

See also