community.general.packet_volume module – Create/delete a volume in Packet host
Note
This module is part of the community.general collection (version 8.6.7).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.packet_volume
.
New in community.general 0.2.0
Synopsis
Create/delete a volume in Packet host.
API is documented at https://www.packet.com/developers/api/#volumes.
Aliases: cloud.packet.packet_volume
Requirements
The below requirements are needed on the host that executes this module.
packet-python >= 1.35
Parameters
Parameter |
Comments |
---|---|
Packet API token. You can also supply it in environment variable |
|
Billing cycle for new volume. Choices:
|
|
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. |
|
Location of the volume. Volumes can only be attached to device in the same location. |
|
UUID of a volume. |
|
Create new volume locked. Choices:
|
|
Selector for API-generated name of the volume |
|
storage_1 for standard tier, storage_2 for premium (performance) tier. Tiers are described at https://www.packet.com/cloud/storage/. Choices:
|
|
ID of project of the device. |
|
Size of the volume in gigabytes. |
|
Snapshot policy for new volume. |
|
How many snapshots to keep, a positive integer. |
|
Frequency of snapshots. Choices:
|
|
Desired state of the volume. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
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 |
Description |
---|---|
The user-defined description of the volume resource. Returned: success Sample: |
|
UUID of specified volume Returned: success Sample: |
|
The API-generated name of the volume resource. Returned: if volume is attached/detached to/from some device Sample: |