-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathjump-boxes.yml
218 lines (209 loc) · 8.89 KB
/
jump-boxes.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright (c) 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
- name: Create a Key Pair
hosts: jump-boxes
handlers:
- name: Signal the key name wait condition handle
command: cfn-signal -s true -r 'The public key file imported.' {{ key_name_wait_condition_handle }}
tasks:
- block:
- name: Create the RSA Key Pair
user: name={{ ansible_user_id }} generate_ssh_key=yes
register: user_result
- name: Import the public key to Amazon EC2
ec2_key:
name: "{{ key_name | mandatory }}"
key_material: "{{ user_result.ssh_public_key }}"
region: "{{ region | mandatory }}"
wait: yes
state: present
notify:
- Signal the key name wait condition handle
- meta: flush_handlers
- ec2_vpc_subnet_facts:
region: "{{ region | mandatory }}"
filters:
subnet-id: "{{ bosh_subnet_id | mandatory }}"
register: ec2_vpc_subnet_facts_result
- set_fact:
bosh_cidr: "{{ ec2_vpc_subnet_facts_result.subnets[0].cidr_block }}"
bosh_availability_zone: "{{ ec2_vpc_subnet_facts_result.subnets[0].availability_zone }}"
- ec2_vpc_subnet_facts:
region: "{{ region | mandatory }}"
filters:
subnet-id: "{{ cf_private_subnet_id | mandatory }}"
register: ec2_vpc_subnet_facts_result
- set_fact:
cf_private_cidr: "{{ ec2_vpc_subnet_facts_result.subnets[0].cidr_block }}"
cf_private_az: "{{ ec2_vpc_subnet_facts_result.subnets[0].availability_zone }}"
- ec2_vpc_subnet_facts:
region: "{{ region | mandatory }}"
filters:
subnet-id: "{{ cf_public_subnet_id | mandatory }}"
register: ec2_vpc_subnet_facts_result
- set_fact:
cf_public_cidr: "{{ ec2_vpc_subnet_facts_result.subnets[0].cidr_block }}"
cf_public_az: "{{ ec2_vpc_subnet_facts_result.subnets[0].availability_zone }}"
- ec2_vpc_subnet_facts:
region: "{{ region | mandatory }}"
filters:
subnet-id: "{{ docker_subnet_id | mandatory }}"
register: ec2_vpc_subnet_facts_result
- set_fact:
docker_cidr: "{{ ec2_vpc_subnet_facts_result.subnets[0].cidr_block }}"
docker_az: "{{ ec2_vpc_subnet_facts_result.subnets[0].availability_zone }}"
- ec2_vpc_route_table_facts:
region: "{{ region | mandatory }}"
filters:
association.subnet-id: "{{ docker_subnet_id | mandatory }}"
register: ec2_vpc_route_table_facts_result
- set_fact:
private_route_table: "{{ ec2_vpc_route_table_facts_result.route_tables | first }}"
when: provider == 'aws'
- block:
- name: Set OpenStack cedentials
set_fact:
openstack: "{{ lookup('file', '/etc/openstack/clouds.yaml') | from_yaml }}"
- os_subnets_facts:
cloud: TAP
filters:
network_id: "{{ bosh_subnet_id | mandatory }}"
- set_fact:
bosh_cidr: "{{ openstack_subnets[0].cidr }}"
bosh_availability_zone: "{{ availability_zone }}"
- os_subnets_facts:
cloud: TAP
region_name: "{{ region | mandatory }}"
filters:
network_id: "{{ cf_private_subnet_id | mandatory }}"
- set_fact:
cf_private_cidr: "{{ openstack_subnets[0].cidr }}"
cf_private_az: "{{ availability_zone }}"
- os_subnets_facts:
cloud: TAP
region_name: "{{ region | mandatory }}"
filters:
network_id: "{{ cf_public_subnet_id | mandatory }}"
- set_fact:
cf_public_cidr: "{{ openstack_subnets[0].cidr }}"
cf_public_az: "{{ availability_zone }}"
- os_subnets_facts:
cloud: TAP
region_name: "{{ region | mandatory }}"
filters:
network_id: "{{ docker_subnet_id | mandatory }}"
- set_fact:
docker_cidr: "{{ openstack_subnets[0].cidr }}"
docker_az: "{{ availability_zone }}"
when: provider == 'openstack'
- name: Set facts with IP of internal services
set_fact:
bosh_ip: "{{ bosh_cidr | nthhost(4) }}"
docker_ip: "{{ docker_cidr | nthhost(4) }}"
nats_ip: "{{ cf_private_cidr | nthhost(6) }}"
- name: Set the key pair used by BOSH
set_fact: bosh_default_key_name={{ key_name | mandatory }}
bosh_private_key={{ user_result.ssh_key_file | default('/root/.ssh/id_rsa') }}
- include: proxy.yml
- name: Install BOSH
hosts: jump-boxes
pre_tasks:
# https://github.com/rvm/rvm/issues/3509
# http://www.nokogiri.org/tutorials/installing_nokogiri.html#ubuntu___debian
- name: Install libgmp
apt: name=libgmp-dev state=present
become: yes
when: ansible_distribution == 'Ubuntu'
- name: Generate passwords
set_fact:
"{{ item }}": "{{ lookup('password', playbook_dir + '/credentials/' + item + ' chars=ascii_letters,digits length=16') }}"
with_items:
- bosh_nats_password
- bosh_redis_password
- bosh_postgres_password
- bosh_registry_password
- bosh_director_password
- bosh_agent_password
- bosh_admin_password
- bosh_hm_password
- bosh_mbus_password
roles:
- { role: rvm_io.rvm1-ruby, become: yes }
- role: bosh
bosh_director_name: "{{ stack | mandatory }}-bosh"
bosh_region: "{{ region | mandatory }}"
environment:
PATH: "{{ rvm1_install_path }}/gems/{{ rvm1_rubies | last }}/bin:{{ ansible_env.PATH }}"
no_proxy: "{{ no_proxy }}"
http_proxy: "{{ http_proxy }}"
https_proxy: "{{ https_proxy }}"
ftp_proxy: "{{ ftp_proxy }}"
post_tasks:
- name: Signal the BOSH Director wait condition handle for AWS
command: cfn-signal -s true -r 'BOSH Director deployed.' {{ bosh_director_wait_condition_handle }}
when: bosh_director_wait_condition_handle and provider == 'aws'
- name: Signal the BOSH Director wait condition handle for OpenStack
command: "{{ bosh_director_wait_condition_handle }} --data-binary '{\"status\": \"SUCCESS\"}'"
when: bosh_director_wait_condition_handle and provider == 'openstack'
- name: Deploy Trusted Analytics Platform
hosts: jump-boxes
pre_tasks:
- name: Generate passwords
set_fact:
"{{ item }}": "{{ lookup('password', playbook_dir + '/credentials/' + item + ' chars=ascii_letters,digits length=16') }}"
with_items:
- cf_bulk_api_password
- cf_ccdb_encryption_key
- cf_staging_upload_password
- cf_ccdb_user_password
- cf_loggregator_endpoint_shared_secret
- cf_nats_password
- cf_admin_secret
- cf_cc_client_secret
- cf_cc_routing_secret
- cf_cloud_controller_username_lookup_secret
- cf_doppler_secret
- cf_gorouter_secret
- cf_login_client_secret
- cf_notifications_client_secret
- cf_uaadb_user_password
# TODO: Create generic role for BOSH deployment.
roles:
- role: tap
cf_director_uuid: "{{ bosh_director_uuid }}"
cf_dns: "{{ bosh_dns }}"
cf_bosh_security_group: "{{ bosh_default_security_groups | first }}"
cf_bosh_stemcell_version: "{{ bosh_stemcell_version }}"
environment:
PATH: "{{ rvm1_install_path }}/gems/{{ rvm1_rubies | last }}/bin:{{ ansible_env.PATH }}"
no_proxy: "{{ no_proxy }}"
http_proxy: "{{ http_proxy }}"
https_proxy: "{{ https_proxy }}"
ftp_proxy: "{{ ftp_proxy }}"
post_tasks:
- name: Signal the Cloud Foundry wait condition handle for AWS
command: cfn-signal -s true -r 'Cloud Foundry deployed.' {{ cf_wait_condition_handle }}
when: cf_wait_condition_handle and provider == 'aws'
- name: Signal the Docker Broker wait condition handle for AWS
command: cfn-signal -s true -r 'Docker Broker deployed.' {{ docker_broker_wait_condition_handle }}
when: docker_broker_wait_condition_handle and provider == 'aws'
- name: Signal the Cloud Foundry wait condition handle for OpenStack
command: "{{ cf_wait_condition_handle }} --data-binary '{\"status\": \"SUCCESS\"}'"
when: cf_wait_condition_handle and provider == 'openstack'
- name: Signal the Docker Broker wait condition handle for OpenStack
command: "{{ docker_broker_wait_condition_handle }} --data-binary '{\"status\": \"SUCCESS\"}'"
when: docker_broker_wait_condition_handle and provider == 'openstack'
# vi:et:sw=2 ts=2 sts=2 ft=ansible