New in version 2.3.
- packet-python
- python >= 2.6
parameter | required | default | choices | comments |
---|---|---|---|---|
auth_token |
no | Packet api token. You can also supply it in env var PACKET_API_TOKEN . | ||
count |
no | The number of devices to create. Count number can be included in hostname via the %d string formatter. | ||
count_offset |
no | From which number to start the count. | ||
device_ids |
no | List of device IDs on which to operate. | ||
facility |
no | Facility slug for device creation. As of 2016, it should be one of [ewr1, sjc1, ams1, nrt1]. | ||
features |
no | Dict with "features" for device creation. See Packet API docs for details. | ||
hostnames |
no | A hostname of a device, or a list of hostnames. If given string or one-item list, you can use the "%d" Python string format to expand numbers from count.If only one hostname, it might be expanded to list if count>1.
aliases: name | ||
lock |
no | Whether to lock a created device. | ||
operating_system |
no | OS slug for device creation. See Packet docs or API for current list. | ||
plan |
no | Plan slug for device creation. See Packet docs or API for current list. | ||
project_id |
yes | ID of project of the device. | ||
state |
no | present |
|
Desired state of the device. |
user_data |
no | None | Userdata blob made available to the machine | |
wait |
no |
|
Whether to wait for the instance to be assigned IP address before returning. | |
wait_timeout |
no | 60 | How long to wait for IP address of new devices before quitting. In seconds. |
# All the examples assume that you have your Packet api token in env var PACKET_API_TOKEN. # You can also pass it to the auth_token parameter of the module instead. # Creating devices - name: create 1 device hosts: localhost tasks: - packet_device: project_id: 89b497ee-5afc-420a-8fb5-56984898f4df hostnames: myserver operating_system: ubuntu_16_04 plan: baremetal_0 facility: sjc1 - name: create 3 ubuntu devices called server-01, server-02 and server-03 hosts: localhost tasks: - packet_device: project_id: 89b497ee-5afc-420a-8fb5-56984898f4df hostnames: server-%02d count: 3 operating_system: ubuntu_16_04 plan: baremetal_0 facility: sjc1 - name: Create 3 coreos devices with userdata, wait until they get IPs and then wait for SSH hosts: localhost tasks: - name: create 3 devices and register their facts packet_device: hostnames: [coreos-one, coreos-two, coreos-three] operating_system: coreos_stable plan: baremetal_0 facility: ewr1 locked: true project_id: 89b497ee-5afc-420a-8fb5-56984898f4df user_data: | #cloud-config ssh_authorized_keys: - ssh-dss AAAAB3NzaC1kc3MAAACBAIfNT5S0ncP4BBJBYNhNPxFF9lqVhfPeu6SM1LoCocxqDc1AT3zFRi8hjIf6TLZ2AA4FYbcAWxLMhiBxZRVldT9GdBXile78kAK5z3bKTwq152DCqpxwwbaTIggLFhsU8wrfBsPWnDuAxZ0h7mmrCjoLIE3CNLDA/NmV3iB8xMThAAAAFQCStcesSgR1adPORzBxTr7hug92LwAAAIBOProm3Gk+HWedLyE8IfofLaOeRnbBRHAOL4z0SexKkVOnQ/LGN/uDIIPGGBDYTvXgKZT+jbHeulRJ2jKgfSpGKN4JxFQ8uzVH492jEiiUJtT72Ss1dCV4PmyERVIw+f54itihV3z/t25dWgowhb0int8iC/OY3cGodlmYb3wdcQAAAIBuLbB45djZXzUkOTzzcRDIRfhaxo5WipbtEM2B1fuBt2gyrvksPpH/LK6xTjdIIb0CxPu4OCxwJG0aOz5kJoRnOWIXQGhH7VowrJhsqhIc8gN9ErbO5ea8b1L76MNcAotmBDeTUiPw01IJ8MdDxfmcsCslJKgoRKSmQpCwXQtN2g== tomk@hp2 coreos: etcd: discovery: https://discovery.etcd.io/6a28e078895c5ec737174db2419bb2f3 addr: $private_ipv4:4001 peer-addr: $private_ipv4:7001 fleet: public-ip: $private_ipv4 units: - name: etcd.service command: start - name: fleet.service command: start register: newhosts - name: wait for ssh wait_for: delay: 1 host: "{{ item.public_ipv4 }}" port: 22 state: started timeout: 500 with_items: "{{ newhosts.devices }}" # Other states of devices - name: remove 3 devices by uuid hosts: localhost tasks: - packet_device: project_id: 89b497ee-5afc-420a-8fb5-56984898f4df state: absent device_ids: - 1fb4faf8-a638-4ac7-8f47-86fe514c30d8 - 2eb4faf8-a638-4ac7-8f47-86fe514c3043 - 6bb4faf8-a638-4ac7-8f47-86fe514c301f
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
changed | True if a device was altered in any way (created, modified or removed) | always | bool | True |
devices | Information about each device that was processed | always | array | [{"hostname": "my-server.com", "id": "server-id", "public-ipv4": "147.229.15.12", "private-ipv4": "10.0.15.12", "public-ipv6": ""2604:1380:2:5200::3"}] |
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
This module is community maintained without core committer oversight.
For more information on what this means please read Module Support
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.