- set_fact:
asg_n:
- "{{ module }}"
- - "{{ stack }}"
- - "{{ country|ternary('c0', '') }}{{ country|default('') }}"
- - "{{ phase|ternary('d0', '') }}{{ phase|default('') }}"
+ - "{{ stack|default() }}"
+ - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
+ - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
+
+- set_fact:
+ partial_subnet_ids: "{{ subnet_ids }}"
+ when: subnet_ids is defined
- name: suss out our subnets
+ when: partial_subnet_ids is not defined
ec2_vpc_subnet_facts:
region: "{{ vpc_region }}"
filters:
propagate_at_launch: yes
- module: "{{ module }}"
propagate_at_launch: yes
- - stack: "{{ stack }}"
+ - stack: "{{ stack|default() }}"
propagate_at_launch: yes
- - country: "{{ country }}"
+ - country: "{{ country|default() }}"
propagate_at_launch: yes
- - phase: "{{ phase }}"
+ - phase: "{{ phase|default() }}"
propagate_at_launch: yes
that:
- MANAGEMENT_SUBNET != ''
- DEFAULT_AMI != ''
+ - version != ''
+ - phase != ''
tags: ['check_vars']
- name: sg management-elb
interval: 30
unhealthy_threshold: 2
healthy_threshold: 2
+ register: elb_management
- name: management key
ec2_key:
# - arn:aws:iam::{{ ACCT_ID }}:policy/base-policy
# - arn:aws:iam::{{ ACCT_ID }}:policy/management-policy
-# will need to rev name-version when changing AMI
-- name: management lc
- ec2_lc:
- region: "{{ vpc_region }}"
- name: management-0000
- image_id: "{{ DEFAULT_AMI }}"
- key_name: "{{ MANAGEMENT_KEY_NAME }}"
- instance_profile_name: management
- security_groups:
- - "{{ sg_management.group_id }}"
- - "{{ sg_ssh.group_id }}"
- instance_type: m4.large
- volumes:
-# setting the root volume seems to prevent instances from launching
-# - 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
+- include_role:
+ name: launchconfig
+ vars:
+ security_group_ids:
+ - "{{ sg_ssh.group_id }}"
+ - "{{ sg_icmp.group_id }}"
+ - "{{ sg_management.group_id }}"
-- name: management asg
- ec2_asg:
- region: "{{ vpc_region }}"
- name: management
+# # will need to rev name-version when changing AMI
+# - name: management lc
+# ec2_lc:
+# region: "{{ vpc_region }}"
+# name: management-0000
+# image_id: "{{ DEFAULT_AMI }}"
+# key_name: "{{ MANAGEMENT_KEY_NAME }}"
+# instance_profile_name: management
+# security_groups:
+# - "{{ sg_management.group_id }}"
+# - "{{ sg_ssh.group_id }}"
+# - "{{ sg_icmp.group_id }}"
+# instance_type: m4.large
+# volumes:
+# # setting the root volume seems to prevent instances from launching
+# # - 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
+
+- include_role:
+ name: autoscalinggroup
+ vars:
+ load_balancers: "{{ elb_management.elb.name }}"
min_size: 1
max_size: 1
- desired_capacity: 1
- default_cooldown: 10
- vpc_zone_identifier: "{{ MANAGEMENT_SUBNET }}"
- launch_config_name: "{{ mgmt_lc.name|default('checkmode') }}"
- notification_topic: "{{ management_topic.sns_arn }}"
- notification_types:
- - autoscaling:EC2_INSTANCE_LAUNCH
- load_balancers:
- - management-int-elb
- tags:
- - account: "{{ ACCT_NAME }}"
- propagate_at_launch: yes
- - module: management
- propagate_at_launch: yes
- - stack: ""
- propagate_at_launch: yes
- - country: ""
- propagate_at_launch: yes
- - phase: dev
- propagate_at_launch: yes
+ subnet_ids: "{{ MANAGEMENT_SUBNET }}"
+
+# - name: management asg
+# ec2_asg:
+# region: "{{ vpc_region }}"
+# name: management
+# min_size: 1
+# max_size: 1
+# desired_capacity: 1
+# default_cooldown: 10
+# vpc_zone_identifier: "{{ MANAGEMENT_SUBNET }}"
+# launch_config_name: "{{ mgmt_lc.name|default('checkmode') }}"
+# notification_topic: "{{ management_topic.sns_arn }}"
+# notification_types:
+# - autoscaling:EC2_INSTANCE_LAUNCH
+# load_balancers:
+# - management-int-elb
+# tags:
+# - account: "{{ ACCT_NAME }}"
+# propagate_at_launch: yes
+# - module: management
+# propagate_at_launch: yes
+# - stack: ""
+# propagate_at_launch: yes
+# - country: ""
+# propagate_at_launch: yes
+# - phase: dev
+# propagate_at_launch: yes
- name: not implemented yet
debug:
- set_fact:
ud_cluster:
- "{{ module }}"
- - "{{ country|ternary('c0', '') }}{{ country|default('') }}"
- - "{{ phase|ternary('d0', '') }}{{ phase|default('') }}"
+ - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
+ - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
- set_fact:
ud_asgn:
- "{{ module }}"
- "{{ stack|default('') }}"
- - "{{ country|ternary('c0', '') }}{{ country|default('') }}"
- - "{{ phase|ternary('d0', '') }}{{ phase|default('') }}"
+ - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
+ - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
- set_fact:
lc_n:
- "{{ module }}"
- "{{ stack|default('') }}"
- - "{{ country|ternary('c0', '') }}{{ country|default('') }}"
- - "{{ phase|ternary('d0', '') }}{{ phase|default('') }}"
+ - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
+ - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
- "{{ version }}"
- name: assemble user data