community.general.packet_volume_attachment – Attach/detach a volume to a device in the Packet host.

Note

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

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.

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

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.
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
    Choices:
  • present ←
  • absent
Indicate desired state of the attachment.
volume
string / required
Selector for the volume.
It can be a UUID, an API-generated volume name, or user-defined description string.
Example values: 4a347482-b546-4f67-8300-fb5018ef0c5, volume-4a347482, "my 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: 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 Returned Description
device_id
string
success
UUID of device addressed by the module call.

volume_id
string
success
UUID of volume addressed by the module call.



Authors