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 1.3.6).
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¶
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.
python >= 2.6
packet-python >= 1.35
Parameters¶
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¶
Tomas Karasek (@t0mk) <tom.to.the.k@gmail.com>
Nurfet Becirevic (@nurfet-becirevic) <nurfet.becirevic@gmail.com>