use common framework for management infrastructure
[awsible] / roles / autoscalinggroup / tasks / main.yml
1 ---
2 - assert:
3 that:
4 - zone in ('pub', 'priv')
5 - module != ''
6 - version != ''
7 - region|default(vpc_region) != ''
8 tags: ['check_vars']
9
10 - set_fact:
11 asg_n:
12 - "{{ module }}"
13 - "{{ stack|default() }}"
14 - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
15 - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
16
17 - set_fact:
18 partial_subnet_ids: "{{ subnet_ids }}"
19 when: subnet_ids is defined
20
21 - name: suss out our subnets
22 when: partial_subnet_ids is not defined
23 ec2_vpc_subnet_facts:
24 region: "{{ vpc_region }}"
25 filters:
26 vpc_id: "{{ vpc.vpc.id }}"
27 "tag:zone": "{{ zone }}"
28 register: partial_subnet_ids
29
30 - name: autoscalinggroup
31 ec2_asg:
32 region: "{{ vpc_region }}"
33 name: "{{ asg_n|select|join('-') }}"
34 min_size: "{{ min_size|default(0) }}"
35 max_size: "{{ max_size|default(omit) }}"
36 desired_capacity: "{{ desired_capacity|default(omit) }}"
37 default_cooldown: 10
38 vpc_zone_identifier: "{{ partial_subnet_ids.subnets|default([])|map(attribute='id')|list }}"
39 launch_config_name: "{{ asg_n|select|join('-') }}-{{ version }}"
40 notification_topic: "{{ management_topic.sns_arn }}"
41 load_balancers: "{{ load_balancers|default(omit) }}"
42 tags:
43 - account: "{{ ACCT_NAME }}"
44 propagate_at_launch: yes
45 - module: "{{ module }}"
46 propagate_at_launch: yes
47 - stack: "{{ stack|default() }}"
48 propagate_at_launch: yes
49 - country: "{{ country|default() }}"
50 propagate_at_launch: yes
51 - phase: "{{ phase|default() }}"
52 propagate_at_launch: yes
53