use common framework for management infrastructure
authorJustin Wind <j.wind@partner.samsung.com>
Tue, 14 Mar 2017 21:25:11 +0000 (14:25 -0700)
committerJustin Wind <j.wind@partner.samsung.com>
Tue, 14 Mar 2017 21:25:11 +0000 (14:25 -0700)
init_management-dev.yml [moved from init_management.yml with 53% similarity]
management-d0dev.yml [moved from management.yml with 67% similarity]
roles/autoscalinggroup/tasks/main.yml
roles/aws-management-infrastructure/defaults/main.yml
roles/aws-management-infrastructure/tasks/main.yml
roles/launchconfig/tasks/main.yml

similarity index 53%
rename from init_management.yml
rename to init_management-dev.yml
index 97302ba231a26e642236d998be450406d578c448..56a41f6c7bbe127816bab61b863c7f1e540ed430 100644 (file)
@@ -4,4 +4,6 @@
   gather_facts: False
   become: no
   roles:
-  - aws-management-infrastructure
+  - role: aws-management-infrastructure
+    phase: dev
+    version: "0000"
similarity index 67%
rename from management.yml
rename to management-d0dev.yml
index a6ce26a434eea1579740489e922b879a5ee052a4..a1e1dc0d8e40ca182939b79d560053da03f3a685 100644 (file)
@@ -1,5 +1,5 @@
 ---
-- hosts: management
+- hosts: management-d0dev
   become: true
   roles:
   - common
index d0c1692acde1e2e75b84586557a252f2dc703259..694f7dce6a860c06c29bd578977603f7d737c0a4 100644 (file)
 - 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
 
index 0db972b3aeb5398c320272412a1db0e01292d855..d2071683148ef21f0926b32d6995d209f0e12a6a 100644 (file)
@@ -4,3 +4,6 @@ MANAGEMENT_EVENT_QUEUE_SHORT: management
 MANAGEMENT_EVENT_FAILURE_QUEUE: "{{ MANAGEMENT_EVENT_QUEUE }}-failed"
 MANAGEMENT_NOTICE_TOPIC: management-notifications
 MANAGEMENT_NOTICE_TOPIC_SHORT: notices
+module: management
+zone: priv
+instance_type: m4.large 
index d0edb77bbf20cb4c439e5e510fc474c981ac4ab2..7db2e1adacc38c4a8a08e45187b92033e48f41e0 100644 (file)
@@ -3,6 +3,8 @@
     that:
     - MANAGEMENT_SUBNET != ''
     - DEFAULT_AMI != ''
+    - version != ''
+    - phase != ''
   tags: ['check_vars']
 
 - name: sg management-elb
@@ -58,6 +60,7 @@
       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:
index 59768fdf2b87257ecdbe3aa48764620dd2f1de41..ced0bcd16dc8f2ae742429f6fc149fc85bde69af 100644 (file)
 - 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