Note
This module is part of the community.general collection (version 10.7.3).
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_attachment.
New in community.general 0.2.0
The below requirements are needed on the host that executes this module.
Parameter | Comments |
|---|---|
auth_token string | Packet API token. You can also supply it in environment variable |
device string | Selector for the device. It can be a UUID of the device, or a hostname. Example values: 98a14f7a-3d27-4478-b7cf-35b5670523f3, “my device”. |
project_id string / required | UUID of the project to which the device and volume belong. |
state string | Indicate desired state of the attachment. Choices:
|
volume string / required | Selector for the volume. It can be a UUID, an API-generated volume name, or user-defined description string. Example values: |
Attribute | Support | Description |
|---|---|---|
check_mode | Support: full | Can run in |
diff_mode | Support: none | Will return details on what has changed (or possibly needs changing in |
# 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: testvol
devname: testdev
project_id: 52000fb2-ee46-4673-93a8-de2c2bdba33b
tasks:
- name: Create volume
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
- name: Create a device
packet_device:
project_id: "{{ project_id }}"
hostnames: "{{ devname }}"
operating_system: ubuntu_16_04
plan: baremetal_0
facility: ewr1
state: present
- name: Attach testvol to testdev
community.general.packet_volume_attachment:
project_id: "{{ project_id }}"
volume: "{{ volname }}"
device: "{{ devname }}"
- name: Detach testvol from testdev
community.general.packet_volume_attachment:
project_id: "{{ project_id }}"
volume: "{{ volname }}"
device: "{{ devname }}"
state: absent
Common return values are documented here, the following are the fields unique to this module:
Key | Description |
|---|---|
device_id string | UUID of device addressed by the module call. Returned: success |
volume_id string | UUID of volume addressed by the module call. Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/packet_volume_attachment_module.html