W3cubDocs

/Ansible 2.11

community.general.packet_volume – Create/delete a volume in Packet host.

Note

This plugin is part of the community.general collection (version 2.0.1).

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.packet_volume.

New in version 0.2.0: of community.general

Synopsis

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.6
  • packet-python >= 1.35

Parameters

Parameter Choices/Defaults Comments
auth_token
string
Packet API token. You can also supply it in env var PACKET_API_TOKEN.
billing_cycle
string
    Choices:
  • hourly
  • monthly
Billing cycle for new volume.
description
string
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.
facility
string
Location of the volume.
Volumes can only be attached to device in the same location.
id
string
UUID of a volume.
locked
boolean
    Choices:
  • no
  • yes
Create new volume locked.
name
string
Selector for API-generated name of the volume
plan
string
    Choices:
  • storage_1
  • storage_2
storage_1 for standard tier, storage_2 for premium (performance) tier.
project_id
string / required
ID of project of the device.
size
integer
Size of the volume in gigabytes.
snapshot_policy
dictionary
Snapshot policy for new volume.
snapshot_count
integer / required
How many snapshots to keep, a positive integer.
snapshot_frequency
string / required
    Choices:
  • 15min
  • 1hour
  • 1day
  • 1week
  • 1month
  • 1year
Frequency of snapshots.
state
string
    Choices:
  • present
  • absent
Desired state of the volume.

Examples

# 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

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
description
string
success
The user-defined description of the volume resource.

Sample:
Just another volume
id
string
success
UUID of specified volume

Sample:
53000fb2-ee46-4673-93a8-de2c2bdba33c
name
string
if volume is attached/detached to/from some device
The API-generated name of the volume resource.

Sample:
volume-a91dc506


Authors

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/community/general/packet_volume_module.html