---
-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
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
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
+
when: ASSET_PATH is defined
file:
state: directory
- path: {{ ASSET_PATH }}
+ path: "{{ ASSET_PATH }}"
mode: "0755"
owner: root
group: root
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
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()