community.general.packet_volume_attachment module – Attach/detach a volume to a device in the Packet host
Note
This module is part of the community.general collection (version 10.7.5).
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
Synopsis
- Attach/detach a volume to a device in the Packet host. 
- API is documented at https://www.packet.com/developers/api/volumes/. 
- This module creates the attachment route in the Packet API. In order to discover the block devices on the server, you have to run the Attach Scripts, as documented at https://help.packet.net/technical/storage/packet-block-storage-linux. 
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  | |
| Selector for the device. It can be a UUID of the device, or a hostname. Example values: 98a14f7a-3d27-4478-b7cf-35b5670523f3, “my device”. | |
| UUID of the project to which the device and volume belong. | |
| Indicate desired state of the attachment. Choices: 
 | |
| Selector for the volume. It can be a UUID, an API-generated volume name, or user-defined description string. Example values:  | 
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: 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
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| UUID of device addressed by the module call. Returned: success | |
| UUID of volume addressed by the module call. Returned: success | 
