community.general.packet_volume_attachment (1.3.11) — module

Attach/detach a volume to a device in the Packet host.

| "added in version" 0.2.0 of community.general"

Authors: Tomas Karasek (@t0mk) <tom.to.the.k@gmail.com>, Nurfet Becirevic (@nurfet-becirevic) <nurfet.becirevic@gmail.com>

Install collection

Install with ansible-galaxy collection install community.general:==1.3.11


Add to requirements.yml

  collections:
    - name: community.general
      version: 1.3.11

Description

Attach/detach a volume to a device in the Packet host.

API is documented at U(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 U(https://help.packet.net/technical/storage/packet-block-storage-linux).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description:
    - Indicate desired state of the attachment.
    type: str

device:
    description:
    - Selector for the device.
    - It can be a UUID of the device, or a hostname.
    - 'Example values: 98a14f7a-3d27-4478-b7cf-35b5670523f3, "my device"'
    type: str

volume:
    description:
    - 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"'
    required: true
    type: str

auth_token:
    description:
    - Packet API token. You can also supply it in env var C(PACKET_API_TOKEN).
    type: str

project_id:
    description:
    - UUID of the project to which the device and volume belong.
    required: true
    type: str

Outputs

device_id:
  description: UUID of device addressed by the module call.
  returned: success
  type: str
volume_id:
  description: UUID of volume addressed by the module call.
  returned: success
  type: str