Commit 53b7baa0 by John Jarvis

Merge pull request #452 from edx/jarv/provision-elb

Jarv/provision elb
parents 5107992b c6151615
...@@ -32,3 +32,23 @@ ...@@ -32,3 +32,23 @@
# gh_users hash must be passed # gh_users hash must be passed
# in as a -e variable # in as a -e variable
- gh_users - gh_users
post_tasks:
- name: get instance id for elb registration
local_action:
module: ec2_lookup
region: us-east-1
tags:
Name: "{{ name_tag }}"
register: ec2_info
when: elb
sudo: False
- name: register instance into an elb if one was provided
local_action:
module: ec2_elb
region: "{{ region }}"
instance_id: "{{ ec2_info.instance_ids[0] }}"
state: present
ec2_elbs:
- "{{ elb }}"
when: elb
sudo: False
...@@ -24,6 +24,16 @@ ...@@ -24,6 +24,16 @@
instance_ids: ${tag_lookup.instance_ids} instance_ids: ${tag_lookup.instance_ids}
when: terminate_instance == true and tag_lookup.instance_ids|length == 1 when: terminate_instance == true and tag_lookup.instance_ids|length == 1
- name: deregister instance from an an elb if it was in one
local_action:
module: ec2_elb
region: "{{ region }}"
instance_id: "{{ tag_lookup.instance_ids[0] }}"
ec2_elbs:
- "{{ elb }}"
state: absent
when: terminate_instance == true and elb and tag_lookup.instance_ids|length == 1
- name: launch_ec2 | Launch ec2 instance - name: launch_ec2 | Launch ec2 instance
local_action: local_action:
module: ec2 module: ec2
...@@ -35,6 +45,7 @@ ...@@ -35,6 +45,7 @@
region: "{{ region }}" region: "{{ region }}"
instance_tags: "{{instance_tags}}" instance_tags: "{{instance_tags}}"
root_ebs_size: "{{ root_ebs_size }}" root_ebs_size: "{{ root_ebs_size }}"
zone: "{{ zone }}"
register: ec2 register: ec2
- name: launch_ec2 | Add DNS name - name: launch_ec2 | Add DNS name
...@@ -90,5 +101,3 @@ ...@@ -90,5 +101,3 @@
delay=60 delay=60
timeout=320 timeout=320
with_items: "{{ ec2.instances }}" with_items: "{{ ec2.instances }}"
...@@ -38,6 +38,18 @@ fi ...@@ -38,6 +38,18 @@ fi
extra_vars="/var/tmp/extra-vars-$$.yml" extra_vars="/var/tmp/extra-vars-$$.yml"
if [[ -z $region ]]; then
region="us-east1"
fi
if [[ -z $zone ]]; then
zone="us-east-1b"
fi
if [[ -z $elb ]]; then
elb="!!null"
fi
if [[ -z $dns_name ]]; then if [[ -z $dns_name ]]; then
dns_name=$github_username dns_name=$github_username
fi fi
...@@ -84,6 +96,7 @@ instance_type: $instance_type ...@@ -84,6 +96,7 @@ instance_type: $instance_type
security_group: $security_group security_group: $security_group
ami: $ami ami: $ami
region: $region region: $region
zone: $zone
instance_tags: '{"environment": "$environment", "github_username": "$github_username", "Name": "$name_tag", "source": "jenkins", "owner": "$BUILD_USER"}' instance_tags: '{"environment": "$environment", "github_username": "$github_username", "Name": "$name_tag", "source": "jenkins", "owner": "$BUILD_USER"}'
root_ebs_size: $root_ebs_size root_ebs_size: $root_ebs_size
name_tag: $name_tag name_tag: $name_tag
...@@ -92,6 +105,7 @@ gh_users: ...@@ -92,6 +105,7 @@ gh_users:
dns_zone: $dns_zone dns_zone: $dns_zone
rabbitmq_refresh: True rabbitmq_refresh: True
GH_USERS_PROMPT: '[$name_tag] ' GH_USERS_PROMPT: '[$name_tag] '
elb: "$elb"
EOF EOF
cat $extra_vars cat $extra_vars
# run the tasks to launch an ec2 instance from AMI # run the tasks to launch an ec2 instance from AMI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment