rax - create / delete an instance in Rackspace Public Cloud

Author:Jesse Keating, Matt Martz

Synopsis

New in version 1.2.

creates / deletes a Rackspace Public Cloud instance and optionally waits for it to be ‘running’.

Options

parameter required default choices comments
api_key no
    Rackspace API key (overrides credentials)
    auth_endpoint no https://identity.api.rackspacecloud.com/v2.0/
      The URI of the authentication service (added in Ansible 1.5)
      auto_increment no True
      • yes
      • no
      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. (added in Ansible 1.5)
      config_drive no
      • yes
      • no
      Attach read-only configuration drive to server as label config-2 (added in Ansible 1.7)
      count no 1
        number of instances to launch (added in Ansible 1.4)
        count_offset no 1
          number count to start at (added in Ansible 1.4)
          credentials no
            File to find the Rackspace credentials in (ignored if api_key and username are provided)
            disk_config no auto
            • auto
            • manual
            Disk partitioning strategy (added in Ansible 1.4)
            env no
              Environment as configured in ~/.pyrax.cfg, see https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#pyrax-configuration (added in Ansible 1.5)
              exact_count no
              • yes
              • no
              Explicitly ensure an exact count of instances, used with state=active/present (added in Ansible 1.4)
              extra_client_args no
                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. (added in Ansible 1.6)
                extra_create_args no
                  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. (added in Ansible 1.6)
                  files no
                    Files to insert into the instance. remotefilename:localcontent
                    flavor no
                      flavor to use for the instance
                      group no
                        host group to assign to server, is also used for idempotent operations to ensure a specific number of instances (added in Ansible 1.4)
                        identity_type no rackspace
                          Authentication machanism to use, such as rackspace or keystone (added in Ansible 1.5)
                          image no
                            image to use for the instance. Can be an id, human_id or name
                            instance_ids no
                              list of instance ids, currently only used when state='absent' to remove instances (added in Ansible 1.4)
                              key_name no
                                key pair to use on the instance
                                meta no
                                  A hash of metadata to associate with the instance
                                  name no
                                    Name to give the instance
                                    networks no ['public', 'private']
                                      The network to attach to the instances. If specified, you must include ALL networks including the public and private interfaces. Can be id or label. (added in Ansible 1.4)
                                      region no DFW
                                        Region to create an instance in
                                        state no present
                                        • present
                                        • absent
                                        Indicate desired state of the resource
                                        tenant_id no
                                          The tenant ID used for authentication (added in Ansible 1.5)
                                          tenant_name no
                                            The tenant name used for authentication (added in Ansible 1.5)
                                            user_data no
                                              Data to be uploaded to the servers config drive. This option implies config_drive. Can be a file path or a string (added in Ansible 1.7)
                                              username no
                                                Rackspace username (overrides credentials)
                                                verify_ssl no
                                                  Whether or not to require SSL validation of API endpoints (added in Ansible 1.5)
                                                  wait no no
                                                  • yes
                                                  • no
                                                  wait for the instance to be in state 'running' before returning
                                                  wait_timeout no 300
                                                    how long before wait gives up, in seconds

                                                    Note

                                                    Requires pyrax

                                                    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
                                                            files:
                                                              /root/.ssh/authorized_keys: /home/localuser/.ssh/id_rsa.pub
                                                              /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
                                                    

                                                    Note

                                                    The following environment variables can be used, RAX_USERNAME, RAX_API_KEY, RAX_CREDS_FILE, RAX_CREDENTIALS, RAX_REGION.

                                                    Note

                                                    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

                                                    Note

                                                    RAX_USERNAME and RAX_API_KEY obviate the use of a credentials file

                                                    Note

                                                    RAX_REGION defines a Rackspace Public Cloud region (DFW, ORD, LON, ...)