Browse Source

changed os2-atomic-proxy to be able to launch inside of both a vpc and classic. Changed STG to default to launching in a vpc, prod still launches in classic.

Thomas Wiest 10 years ago
parent
commit
ddf12084e1

+ 30 - 2
playbooks/aws/os2-atomic-proxy/launch.yml

@@ -8,12 +8,35 @@
     inst_region: us-east-1
     atomic_ami: ami-8e239fe6
     user_data_file: user_data.txt
+    oo_vpc_subnet_id:    # Purposely left blank, these are here to be overridden in env vars_files
+    oo_assign_public_ip: # Purposely left blank, these are here to be overridden in env vars_files
 
   vars_files:
     - vars.yml
+    - "vars.{{ oo_env }}.yml"
 
   tasks:
-    - name: Launch instances
+    - name: Launch instances in VPC
+      ec2:
+        state: present
+        region: "{{ inst_region }}"
+        keypair: mmcgrath_libra
+        group_id: "{{ oo_security_group_ids }}"
+        instance_type: m3.large
+        image: "{{ atomic_ami }}"
+        count: "{{ oo_new_inst_names | oo_len }}"
+        user_data: "{{ lookup('file', user_data_file) }}"
+        wait: yes
+        assign_public_ip: "{{ oo_assign_public_ip }}"
+        vpc_subnet_id: "{{ oo_vpc_subnet_id }}"
+      when: oo_vpc_subnet_id
+      register: ec2_vpc
+
+    - set_fact:
+        ec2: "{{ ec2_vpc }}"
+      when: oo_vpc_subnet_id
+
+    - name: Launch instances in Classic
       ec2:
         state: present
         region: "{{ inst_region }}"
@@ -24,7 +47,12 @@
         count: "{{ oo_new_inst_names | oo_len }}"
         user_data: "{{ lookup('file', user_data_file) }}"
         wait: yes
-      register: ec2
+      when: not oo_vpc_subnet_id
+      register: ec2_classic
+
+    - set_fact:
+        ec2: "{{ ec2_classic }}"
+      when: not oo_vpc_subnet_id
 
     - name: Add new instances public IPs to the atomic proxy host group
       add_host: "hostname={{ item.public_ip }} groupname=new_ec2_instances"

+ 7 - 0
playbooks/aws/os2-atomic-proxy/vars.stg.yml

@@ -1,3 +1,10 @@
 ---
 oo_env_long: staging
 oo_zabbix_hostgroups: ['STG Environment']
+oo_vpc_subnet_id: subnet-700bdd07
+oo_assign_public_ip: yes
+oo_security_group_ids:
+  - sg-02c2f267 # Libra (vpc)
+  - sg-f0bfbe95 # stg (vpc)
+  - sg-a3bfbec6 # stg_proxy (vpc)
+  - sg-d4bfbeb1 # stg_proxy_atomic (vpc)