assorted small fixes, add some management infrastructure
authorJustin Wind <j.wind@partner.samsung.com>
Mon, 5 Dec 2016 18:34:05 +0000 (10:34 -0800)
committerJustin Wind <j.wind@partner.samsung.com>
Mon, 5 Dec 2016 18:34:05 +0000 (10:34 -0800)
group_vars/all
inventory/asg-inventory.py
roles/aws-infrastructure/tasks/main.yml
roles/common/tasks/main.yml
sqs-action.py

index 257b7ad7d97e5710f9da1eb3cf9ed35978d0a1dc..9303d43d61fbb95ad79b3d8378c90c75cdde8a9e 100644 (file)
@@ -1,3 +1,4 @@
 ---
-ACCT_ID: 123456789012
+ACCT_ID: "123456789012"
 VPC_SUBNETS: "subnet-1234abcd,subnet-5678ef01"
+DEFAULT_AMI: "ami-b04e92d0" # Amazon Linux AMI 2016.09.0
\ No newline at end of file
index 74e21b0d1af3adf73de42499b64f18d2e2e40655..1eba92e66e0b93813d267964bd5362dec2694193 100755 (executable)
@@ -68,7 +68,7 @@ def regionInventory(sessionArgs, publicIPs=False):
     inventory = {iid:[AllInstanceIPs[iid]] for iid in AllInstanceIPs}
 
     # add ASG dict, replacing ASG Instance Id with instance IP
-    inventory.update({asg:[AllInstanceIPs[iid] for iid in ASGs[asg]] for asg in ASGs})
+    inventory.update({asg:[AllInstanceIPs[iid] for iid in ASGs[asg] if iid in AllInstanceIPs] for asg in ASGs})
 
     return inventory
 
index 49bc640798a940ca767bda7e18a31c09098fd90b..0f1a39073aa713ed1db8ee5a59f8d79be2bd2416 100644 (file)
         interval: 30
         unhealthy_threshold: 2
         healthy_threshold: 2
+
+  - name: management iam
+    iam:
+      name: management
+      iam_type: role
+      state: present
+
+  - name: management lc
+    ec2_lc:
+      name: management-0000
+      image_id: "{{ DEFAULT_AMI }}"
+      key_name: management-key
+      security_groups:
+      - management
+      - sshOnly
+      instance_type: m4.large
+      volumes:
+      - device_name: /dev/sda1
+        volume_size: 8
+        volume_type: gp2
+        delete_on_termination: true
+      - device_name: /dev/sdb
+        ephemeral: ephemeral0
+      - device_name: /dev/sdc
+        ephemeral: ephemeral1
+      - device_name: /dev/sdd
+        ephemeral: ephemeral2
+      - device_name: /dev/sde
+        ephemeral: ephemeral3
+    register: mgmt_lc
+
+  - name: management asg
+    ec2_asg:
+      name: management
+      min_size: 1
+      max_size: 1
+      desired_capacity: 1
+      vpc_zone_identifier: "{{ MANAGEMENT_SUBNET }}"
+      launch_config_name: "{{ mgmt_lc.something.name }}"
+      tags:
+      - module: management
+        propogate_at_launch: yes
+
index 02f3b0ad88681c70a0b3d853fa046b060d636a65..b92b5174c4aec46dd83c560563221b396dbacd2f 100644 (file)
@@ -5,7 +5,7 @@
   when: ASSET_PATH is defined
   file:
     state: directory
-    path: {{ ASSET_PATH }}
+    path: "{{ ASSET_PATH }}"
     mode: "0755"
     owner: root
     group: root
@@ -49,7 +49,7 @@
   with_items: "{{ fact_scripts|default(None) }}"
   copy:
     dest: /etc/ansible/facts.d/{{ item }}.fact
-    src: {{ item }}.fact
+    src: "{{ item }}.fact"
     mode: "0755"
     owner: root
     group: root
index 54f2eb7969cd48b4a879eeac8829dc4315d85b84..f092fd76b99dcb8d8c43abcf647933fee61bea5d 100755 (executable)
@@ -62,12 +62,13 @@ def processMessage(message):
                 instanceState = ec2r.Instance(InstanceId).state['Name']
             except:
                 logging.debug('instance %s does not exist', InstanceId)
-                message.delete()
+                message.change_visibility(VisibilityTimeout=60 * 2)
             else:
                 if instanceState == 'running':
                     handleEvent(message, event, ASGName, InstanceId)
                 else:
                     logging.debug('instance %s is in state %s, will try again', InstanceId, instanceState)
+                    message.change_visibility(VisibilityTimeout=60 * 2)
         else:
             logging.debug('nothing to do for event %r', data)
             message.delete()