Commit b04fd888 by e0d

Merge pull request #1528 from edx/e0d/minos-fixes

refactoring
parents f101adcf 763cb84c
......@@ -41,6 +41,18 @@ class LifecycleInventory():
parser = argparse.ArgumentParser()
self.profile = profile
def get_e_d_from_tags(self, group):
environment = "default_environment"
deployment = "default_deployment"
for r in group.tags:
if r.key == "environment":
environment = r.value
elif r.key == "deployment":
deployment = r.value
return environment,deployment
def get_instance_dict(self):
ec2 = boto.connect_ec2(profile_name=self.profile)
reservations = ec2.get_all_instances()
......@@ -65,8 +77,10 @@ class LifecycleInventory():
private_ip_address = instances[instance.instance_id].private_ip_address
if private_ip_address:
environment,deployment = self.get_e_d_from_tags(group)
inventory[environment + "_" + deployment + "_" + instance.lifecycle_state.replace(":","_")].append(private_ip_address)
inventory[group.name].append(private_ip_address)
inventory[group.name + "_" + instance.lifecycle_state].append(private_ip_address)
inventory[group.name + "_" + instance.lifecycle_state.replace(":","_")].append(private_ip_address)
inventory[instance.lifecycle_state.replace(":","_")].append(private_ip_address)
print json.dumps(inventory, sort_keys=True, indent=2)
......
# ansible-playbook -i ./lifecycle_inventory.py ./retire_host.yml
# -e@/vars/env.yml --limit Terminating_Wait
# -e@/vars/env.yml --limit Terminating_Wait -e TARGET="Terminating_Wait"
#
# Note that the target now must be specified as an argument
#
#
# This is separate because it's use of handlers
# leads to various race conditions.
#
- name: Stop all services
hosts: Terminating_Wait
hosts: "{{TARGET}}"
sudo: True
gather_facts: False
vars:
......@@ -15,7 +18,7 @@
- stop_all_edx_services
- name: Server retirement workflow
hosts: Terminating_Wait
hosts: "{{TARGET}}"
sudo: True
gather_facts: False
tasks:
......@@ -38,7 +41,7 @@
command: /edx/bin/send-logs-to-s3 -d "{{ COMMON_LOG_DIR }}/tracking/*" -b "{{ COMMON_AWS_SYNC_BUCKET }}/logs/tracking"
- name: Run minos verification
hosts: Terminating_Wait
hosts: "{{TARGET}}"
sudo: True
gather_facts: False
tasks:
......
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