community.general.packet_volume (8.5.0) — module

Create/delete a volume in Packet host

| "added in version" 0.2.0 of community.general"

Authors: Tomas Karasek (@t0mk) <tom.to.the.k@gmail.com>, Nurfet Becirevic (@nurfet-becirevic) <nurfet.becirevic@gmail.com>

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Create/delete a volume in Packet host.

API is documented at U(https://www.packet.com/developers/api/#volumes).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# All the examples assume that you have your Packet API token in env var PACKET_API_TOKEN.
# You can also pass the api token in module param auth_token.

- hosts: localhost
  vars:
    volname: testvol123
    project_id: 53000fb2-ee46-4673-93a8-de2c2bdba33b

  tasks:
    - name: Create volume
      community.general.packet_volume:
        description: "{{ volname }}"
        project_id: "{{ project_id }}"
        facility: 'ewr1'
        plan: 'storage_1'
        state: present
        size: 10
        snapshot_policy:
          snapshot_count: 10
          snapshot_frequency: 1day
      register: result_create

    - name: Delete volume
      community.general.packet_volume:
        id: "{{ result_create.id }}"
        project_id: "{{ project_id }}"
        state: absent

Inputs

    
id:
    description:
    - UUID of a volume.
    type: str

name:
    description:
    - Selector for API-generated name of the volume
    type: str

plan:
    choices:
    - storage_1
    - storage_2
    default: storage_1
    description:
    - storage_1 for standard tier, storage_2 for premium (performance) tier.
    - Tiers are described at U(https://www.packet.com/cloud/storage/).
    type: str

size:
    description:
    - Size of the volume in gigabytes.
    type: int

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Desired state of the volume.
    type: str

locked:
    default: false
    description:
    - Create new volume locked.
    type: bool

facility:
    description:
    - Location of the volume.
    - Volumes can only be attached to device in the same location.
    type: str

auth_token:
    description:
    - Packet API token. You can also supply it in environment variable E(PACKET_API_TOKEN).
    type: str

project_id:
    description:
    - ID of project of the device.
    required: true
    type: str

description:
    description:
    - User-defined description attribute for Packet volume.
    - It is used used as idempotent identifier - if volume with given description exists,
      new one is not created.
    type: str

billing_cycle:
    choices:
    - hourly
    - monthly
    default: hourly
    description:
    - Billing cycle for new volume.
    type: str

snapshot_policy:
    description:
    - Snapshot policy for new volume.
    suboptions:
      snapshot_count:
        description:
        - How many snapshots to keep, a positive integer.
        required: true
        type: int
      snapshot_frequency:
        choices:
        - 15min
        - 1hour
        - 1day
        - 1week
        - 1month
        - 1year
        description:
        - Frequency of snapshots.
        required: true
        type: str
    type: dict

Outputs

description:
  description: The user-defined description of the volume resource.
  returned: success
  sample: Just another volume
  type: str
id:
  description: UUID of specified volume
  returned: success
  sample: 53000fb2-ee46-4673-93a8-de2c2bdba33c
  type: str
name:
  description: The API-generated name of the volume resource.
  returned: if volume is attached/detached to/from some device
  sample: volume-a91dc506
  type: str