Getting Started With Ansible and Rackspace P2

Posted on Thu 01 October 2015 in Computing


In this post a simple playbook is demonstrated to provision a pseudo DC in Rackspace.

Following on from the previous post, a parametrised playbook is created to:

-  Install a keypair from a file - Create a management network - Create a domain name

This playbook will likely only be run once

Create Datacenter Playbook (rs_create_dc.yml)

# rs_create_dc.yml
 -  name: Create Rackspace DC
    hosts: localhost
    connection: local
    gather_facts: false

      - region: LON
      - management_net_cidr:
      - domain_contact: dns@{{ domain_name }}

      - name: Create KeyPair
          name: rs_kp
          region: "{{ region }}"
          public_key: "{{ ssh_key }}"

      - name: Create Management Network
          label: management
          cidr: "{{ management_net_cidr }}"
          region: "{{ region }}"

      - name: Add Domain Name
          name: "{{ domain_name }}"
          email: "{{ domain_contact }}"
          region: "{{ region }}"

The playbook might then be run like this:

ansible-playbook  rs_create_dc.yml -e "ssh_key=/home/user/.ssh/"