rax_keypair – Create a keypair for use with Rackspace Cloud Servers

Synopsis

  • Create a keypair for use with Rackspace Cloud Servers

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.

aliases: password
auth_endpoint
-
Default:
"https://identity.api.rackspacecloud.com/v2.0/"
The URI of the authentication service.
credentials
-
File to find the Rackspace credentials in. Ignored if api_key and username are provided.

aliases: creds_file
env
-
identity_type
-
Default:
"rackspace"
Authentication mechanism to use, such as rackspace or keystone.
name
- / required
Name of keypair
public_key
-
Public Key string to upload. Can be a file path or string
region
-
Default:
"DFW"
Region to create an instance in.
state
-
    Choices:
  • present ←
  • absent
Indicate desired state of the resource
tenant_id
-
The tenant ID used for authentication.
tenant_name
-
The tenant name used for authentication.
username
-
Rackspace username, overrides credentials.
validate_certs
boolean
    Choices:
  • no
  • yes
Whether or not to require SSL validation of API endpoints.

aliases: verify_ssl

Notes

Note

  • Keypairs cannot be manipulated, only created and deleted. To “update” a keypair you must first delete and then recreate.
  • The ability to specify a file path for the public key was added in 1.7
  • The following environment variables can be used, RAX_USERNAME, RAX_API_KEY, RAX_CREDS_FILE, RAX_CREDENTIALS, RAX_REGION.
  • RAX_CREDENTIALS and RAX_CREDS_FILE points to a credentials file appropriate for pyrax. See https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating
  • RAX_USERNAME and RAX_API_KEY obviate the use of a credentials file
  • RAX_REGION defines a Rackspace Public Cloud region (DFW, ORD, LON, …)

Examples

- name: Create a keypair
  hosts: localhost
  gather_facts: False
  tasks:
    - name: keypair request
      local_action:
        module: rax_keypair
        credentials: ~/.raxpub
        name: my_keypair
        region: DFW
      register: keypair
    - name: Create local public key
      local_action:
        module: copy
        content: "{{ keypair.keypair.public_key }}"
        dest: "{{ inventory_dir }}/{{ keypair.keypair.name }}.pub"
    - name: Create local private key
      local_action:
        module: copy
        content: "{{ keypair.keypair.private_key }}"
        dest: "{{ inventory_dir }}/{{ keypair.keypair.name }}"

- name: Create a keypair
  hosts: localhost
  gather_facts: False
  tasks:
    - name: keypair request
      local_action:
        module: rax_keypair
        credentials: ~/.raxpub
        name: my_keypair
        public_key: "{{ lookup('file', 'authorized_keys/id_rsa.pub') }}"
        region: DFW
      register: keypair

Status

Authors

  • Matt Martz (@sivel)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.