diff --git a/dynamicInventory b/dynamicInventory new file mode 100755 index 0000000000000000000000000000000000000000..bfb6b4b9bf9c00dcda7ca7d65b6a51391219e04e --- /dev/null +++ b/dynamicInventory @@ -0,0 +1,50 @@ +#!/usr/bin/env python +import sys, os, string, subprocess, socket, re +import copy, shlex,uuid, random, multiprocessing, time, shutil, json +import novaclient.v1_1.client as nvclient +import novaclient.exceptions as nvexceptions + +class Authenticate: + + def __init__(self, username, passwd): + self.username=username + self.passwd=passwd + self.tenantName= os.environ['OS_TENANT_NAME'] + self.tenantID= os.environ['OS_TENANT_ID'] + self.authUrl="https://keystone.rc.nectar.org.au:5000/v2.0" + + def gatherInfo(self): + + ## Fetch the Nova Object + + nc = nvclient.Client( auth_url=self.authUrl, + username=self.username, + api_key=self.passwd, + project_id=self.tenantName, + tenant_id=self.tenantID, + service_type="compute" + ) + inventory = {} + inventory['_meta'] = { 'hostvars': {} } + for server in nc.servers.list(): + if server.metadata: + hostname = socket.gethostbyaddr(server.networks.values()[0][0])[0] + # Set Ansible Host Group + if server.metadata['ansible_host_group'] in inventory: + inventory[server.metadata['ansible_host_group']].append(hostname) + else: + inventory[server.metadata['ansible_host_group']] = [hostname] + # Set the other host variables + inventory['_meta']['hostvars'][hostname] = {} + inventory['_meta']['hostvars'][hostname]['ansible_ssh_user'] = server.metadata['ansible_ssh_user'] + inventory['_meta']['hostvars'][hostname]['ansible_ssh_private_key_file'] = server.metadata['ansible_ssh_private_key_file'] + + else: + continue + print json.dumps(inventory) + +if __name__ == "__main__": + username = os.environ['OS_USERNAME'] + passwd = os.environ['OS_PASSWORD'] + auth = Authenticate(username, passwd) + auth.gatherInfo() diff --git a/headNode.yaml b/headNode.yaml new file mode 100644 index 0000000000000000000000000000000000000000..22c1e0e7be63f7cd471c988e5bab34e99f0f10a4 --- /dev/null +++ b/headNode.yaml @@ -0,0 +1,43 @@ +--- +description: " A simple template to boot a 3 node cluster" +heat_template_version: 2013-05-23 +parameters: + image_id: + type: string + label: Image ID + description: Image to be used for compute instance + default: a5e74703-f343-415a-aa23-bd0f0aacfc9e + key_name: + type: string + label: Key Name + description: Name of key-pair to be used for compute instance + default: shahaan + availability_z: + type: string + label: Availability Zone + description: Availability Zone to be used for launching compute instance + default: monash-01 +resources: + headNode: + type: "OS::Nova::Server" + properties: + availability_zone: { get_param: availability_z } + flavor: m1.small + image: { get_param: image_id } + key_name: { get_param: key_name } + metadata: + ansible_host_group: headNode + ansible_ssh_user: ec2-user + ansible_ssh_private_key_file: /home/sgeadmin/.ssh/shahaan.pem + headVolume: + type: OS::Cinder::Volume + properties: + availability_zone: { get_param: availability_z } + description: Volume that will attach the headNode + name: headNodeVolume + size: 50 + volumeAttachment: + type: OS::Cinder::VolumeAttachment + properties: + instance_uuid: { get_resource: headNode } + volume_id: { get_resource: headVolume } diff --git a/installNFS.yml b/installNFS.yml index 3512ff2c8d9dc2f5be3302a3090f1427f21e40f8..01aff573bfbb9bbfbbd632941c8fe2c9f064764e 100644 --- a/installNFS.yml +++ b/installNFS.yml @@ -3,10 +3,7 @@ hosts: openvpn-servers remote_user: ec2-user roles: - - easy-rsa-common - - easy-rsa-CA - - easy-rsa-certificate - - OpenVPN-Server + #- OpenVPN-Server - nfs-server sudo: true vars: @@ -15,9 +12,9 @@ hosts: openvpn-clients remote_user: ec2-user roles: - - easy-rsa-common - - easy-rsa-certificate - - OpenVPN-Client + #- easy-rsa-common + #- easy-rsa-certificate + #- OpenVPN-Client - syncExports - nfs-client sudo: true diff --git a/provisionCluster.yaml b/provisionCluster.yaml new file mode 100644 index 0000000000000000000000000000000000000000..910d5ea4192c1e29d1f490c4505fb49d4e771d99 --- /dev/null +++ b/provisionCluster.yaml @@ -0,0 +1,41 @@ +--- +description: " A simple template to boot a 3 node cluster" +heat_template_version: 2013-05-23 +parameters: + image_id: + type: string + label: Image ID + description: Image to be used for compute instance + default: a5e74703-f343-415a-aa23-bd0f0aacfc9e + key_name: + type: string + label: Key Name + description: Name of key-pair to be used for compute instance + default: shahaan + availability_z: + type: string + label: Availability Zone + description: Availability Zone to be used for launching compute instance + default: monash-01 +resources: + computeNodes: + type: "OS::Heat::ResourceGroup" + properties: + count: 2 + resource_def: + type: "OS::Nova::Server" + properties: + availability_zone: { get_param: availability_z } + flavor: m1.small + image: { get_param: image_id } + key_name: { get_param: key_name } + metadata: + ansible_host_group: computeNodes + ansible_ssh_user: ec2-user + ansible_ssh_private_key_file: /home/sgeadmin/.ssh/shahaan.pem + headNodes: + type: "OS::Heat::ResourceGroup" + properties: + count: 1 + resource_def: + type: headNode.yaml