use common framework for management infrastructure
[awsible] / roles / launchconfig / tasks / main.yml
1 ---
2 - assert:
3 that:
4 - module != ''
5 - version != ''
6 - ami|default(DEFAULT_AMI) != ''
7 - region|default(vpc_region) != ''
8 - security_group_ids != ''
9 - instance_type != ''
10 tags: ['check_vars']
11
12 - set_fact:
13 ud_cluster:
14 - "{{ module }}"
15 - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
16 - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
17
18 - set_fact:
19 ud_asgn:
20 - "{{ module }}"
21 - "{{ stack|default('') }}"
22 - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
23 - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
24
25 - set_fact:
26 lc_n:
27 - "{{ module }}"
28 - "{{ stack|default('') }}"
29 - "{{ (country|default() != '')|ternary('c0', '') }}{{ country|default('') }}"
30 - "{{ (phase|default() != '')|ternary('d0', '') }}{{ phase|default('') }}"
31 - "{{ version }}"
32
33 - name: assemble user data
34 set_fact:
35 user_data:
36 EC2_REGION: "{{ region|default(vpc_region) }}"
37 CLOUD_COUNTRIES: "{{ country|default() }}"
38 CLOUD_ENVIRONMENT: "{{ ACCT_NAME }}"
39 CLOUD_MONITOR_BUCKET: "{{ module }}"
40 CLOUD_APP: "{{ module }}"
41 CLOUD_STACK: "{{ stack|default('None') }}"
42 CLOUD_DEV_PHASE: "{{ phase|default() }}"
43 CLOUD_CLUSTER: "{{ ud_cluster|select|join('-') }}"
44 CLOUD_AUTO_SCALE_GROUP: "{{ ud_asgn|select|join('-') }}"
45 CLOUD_LAUNCH_CONFIG: "{{ lc_n|select|join('-') }}"
46
47 - name: launchconfig
48 ec2_lc:
49 region: "{{ region|default(vpc_region) }}"
50 name: "{{ lc_n|select|join('-') }}"
51 image_id: "{{ ami|default(DEFAULT_AMI) }}"
52 key_name: "{{ MANAGEMENT_KEY_NAME }}"
53 instance_profile_name: "{{ module }}"
54 security_groups: "{{ security_group_ids }}"
55 instance_type: "{{ instance_type}}"
56 volumes:
57 # setting the root volume seems to prevent instances from launching
58 # - device_name: /dev/sda
59 # volume_size: 8
60 # volume_type: gp2
61 # delete_on_termination: true
62 - device_name: /dev/sdb
63 ephemeral: ephemeral0
64 - device_name: /dev/sdc
65 ephemeral: ephemeral1
66 - device_name: /dev/sdd
67 ephemeral: ephemeral2
68 - device_name: /dev/sde
69 ephemeral: ephemeral3
70 user_data: "{{ lookup('template', 'userdata.sh.j2') }}"
71 register: launchconfig