---

- name: Provision a Rackspace Cloud Server instance
  hosts: localhost
  gather_facts: no
  tasks:
    - name: ensure the devstack instance is created
      local_action:
        module: rax
        api_key: "{{ openstack_env_password }}"
        auto_increment: yes
        flavor: "performance1-4" # 4 GB Performance
        image: "Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)"
        files:
          /root/.ssh/authorized_keys: ~/.ssh/id_rsa.pub
        group: devstack
        name: "devstack"
        region: "{{ openstack_env_region_name }}"
        state: present
        tenant_id: "{{ openstack_env_tenant_id }}"
        username: "{{ openstack_env_username }}"
        wait: yes
        wait_timeout: 300 # 5 minutes
      register: raxcloud

    - name: ensure the instance is added to a host group
      local_action: add_host name={{ item.accessIPv4 }} hostname={{ item.name }} ansible_ssh_user=root ansible_ssh_private_key_file=~/.ssh/id_rsa groupname=raxhosts
      with_items: raxcloud.instances

    - name: ensure the inventory file is created
      local_action: shell echo "devstack ansible_ssh_host={{ item.accessIPv4 }} ansible_ssh_port=22 ansible_ssh_user=root ansible_ssh_private_key_file=~/.ssh/id_rsa" >> hosts-raxcloud #"
      with_items: raxcloud.instances

    - name: ensure instance is responding
      local_action: wait_for host={{ item.accessIPv4 }} port=22 delay=10 timeout=60
      with_items: raxcloud.instances

- name: Configure the Rackspace Cloud Server instance
  hosts: raxhosts
  gather_facts: yes
  roles:
    - common
    - devstack

Add playbook to deploy DevStack on a Rackspace Cloud Server
Add playbook to deploy DevStack on a Rackspace Cloud Server
