rax – create / delete an instance in Rackspace Public Cloud
rax – create / delete an instance in Rackspace Public Cloud
Synopsis
- creates / deletes a Rackspace Public Cloud instance and optionally waits for it to be ‘running’.
Requirements
The below requirements are needed on the host that executes this module.
- python >= 2.6
- pyrax
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
api_key - |
Rackspace API key, overrides credentials.
| |
auth_endpoint - added in 1.5 |
Default: |
The URI of the authentication service. |
auto_increment boolean added in 1.5 |
|
Whether or not to increment a single number with the name of the created servers. Only applicable when used with the group attribute or meta key. |
boot_from_volume boolean added in 1.9 |
|
Whether or not to boot the instance from a Cloud Block Storage volume. If |
boot_volume - added in 1.9 |
Cloud Block Storage ID or Name to use as the boot volume of the instance | |
boot_volume_size - added in 1.9 |
Default: 100 |
Size of the volume to create in Gigabytes. This is only required with image and boot_from_volume. |
boot_volume_terminate boolean added in 1.9 |
|
Whether the boot_volume or newly created volume from image will be terminated when the server is terminated |
config_drive boolean added in 1.7 |
|
Attach read-only configuration drive to server as label config-2 |
count - added in 1.4 |
Default: 1 |
number of instances to launch |
count_offset - added in 1.4 |
Default: 1 |
number count to start at |
credentials - |
File to find the Rackspace credentials in. Ignored if api_key and username are provided.
| |
disk_config - added in 1.4 |
|
Disk partitioning strategy |
env - added in 1.5 |
Environment as configured in ~/.pyrax.cfg, see https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#pyrax-configuration. | |
exact_count boolean added in 1.4 |
|
Explicitly ensure an exact count of instances, used with state=active/present. If specified as |
extra_client_args - added in 1.6 |
A hash of key/value pairs to be used when creating the cloudservers client. This is considered an advanced option, use it wisely and with caution. | |
extra_create_args - added in 1.6 |
A hash of key/value pairs to be used when creating a new server. This is considered an advanced option, use it wisely and with caution. | |
files - |
Files to insert into the instance. remotefilename:localcontent | |
flavor - |
flavor to use for the instance | |
group - added in 1.4 |
host group to assign to server, is also used for idempotent operations to ensure a specific number of instances | |
identity_type - added in 1.5 |
Default: "rackspace" |
Authentication mechanism to use, such as rackspace or keystone. |
image - |
image to use for the instance. Can be an | |
instance_ids - added in 1.4 |
list of instance ids, currently only used when state='absent' to remove instances | |
key_name - |
key pair to use on the instance
| |
meta - |
A hash of metadata to associate with the instance | |
name - |
Name to give the instance | |
networks - added in 1.4 |
Default: ["public", "private"] |
The network to attach to the instances. If specified, you must include ALL networks including the public and private interfaces. Can be |
region - |
Default: "DFW" |
Region to create an instance in. |
state - |
|
Indicate desired state of the resource |
tenant_id - added in 1.5 |
The tenant ID used for authentication. | |
tenant_name - added in 1.5 |
The tenant name used for authentication. | |
user_data - added in 1.7 |
Data to be uploaded to the servers config drive. This option implies config_drive. Can be a file path or a string | |
username - |
Rackspace username, overrides credentials. | |
verify_ssl - added in 1.5 |
Whether or not to require SSL validation of API endpoints. | |
wait boolean |
|
wait for the instance to be in state 'running' before returning |
wait_timeout - |
Default: 300 |
how long before wait gives up, in seconds |
Notes
Note
- exact_count can be “destructive” if the number of running servers in the group is larger than that specified in count. In such a case, the state is effectively set to
absent
and the extra servers are deleted. In the case of deletion, the returned data structure will haveaction
set todelete
, and the oldest servers in the group will be deleted. - The following environment variables can be used,
RAX_USERNAME
,RAX_API_KEY
,RAX_CREDS_FILE
,RAX_CREDENTIALS
,RAX_REGION
. RAX_CREDENTIALS
andRAX_CREDS_FILE
points to a credentials file appropriate for pyrax. See https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticatingRAX_USERNAME
andRAX_API_KEY
obviate the use of a credentials fileRAX_REGION
defines a Rackspace Public Cloud region (DFW, ORD, LON, …)
Examples
- name: Build a Cloud Server
gather_facts: False
tasks:
- name: Server build request
local_action:
module: rax
credentials: ~/.raxpub
name: rax-test1
flavor: 5
image: b11d9567-e412-4255-96b9-bd63ab23bcfe
key_name: my_rackspace_key
files:
/root/test.txt: /home/localuser/test.txt
wait: yes
state: present
networks:
- private
- public
register: rax
- name: Build an exact count of cloud servers with incremented names
hosts: local
gather_facts: False
tasks:
- name: Server build requests
local_action:
module: rax
credentials: ~/.raxpub
name: test%03d.example.org
flavor: performance1-1
image: ubuntu-1204-lts-precise-pangolin
state: present
count: 10
count_offset: 10
exact_count: yes
group: test
wait: yes
register: rax
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Jesse Keating (@omgjlk)
- Matt Martz (@sivel)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.7/modules/rax_module.html