ciinabox-ecs 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +458 -0
- data/Rakefile +649 -0
- data/bin/Rakefile +1 -0
- data/bin/ciinabox-ecs +2 -0
- data/bin/ciinabox-ecs.rb +60 -0
- data/config/ciinabox_params.yml.erb +71 -0
- data/config/default_lambdas.yml +26 -0
- data/config/default_params.yml +303 -0
- data/config/default_params.yml.example +124 -0
- data/config/default_services.yml +62 -0
- data/ext/common_helper.rb +21 -0
- data/ext/config/managed_policies.yml +156 -0
- data/ext/helper.rb +29 -0
- data/ext/policies.rb +53 -0
- data/ext/zip_helper.rb +57 -0
- data/lambdas/acm_issuer_validator/lib/install.sh +20 -0
- data/templates/bastion.rb +121 -0
- data/templates/ciinabox.rb +159 -0
- data/templates/ecs-cluster.rb +252 -0
- data/templates/ecs-services.rb +340 -0
- data/templates/lambdas.rb +172 -0
- data/templates/services/bitbucket.rb +81 -0
- data/templates/services/drone.rb +394 -0
- data/templates/services/hawtio.rb +100 -0
- data/templates/services/icinga2.rb +79 -0
- data/templates/services/jenkins.rb +209 -0
- data/templates/services/nexus.rb +96 -0
- data/templates/vpc.rb +290 -0
- metadata +144 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'cfndsl'
|
2
|
+
require_relative '../../ext/helper'
|
3
|
+
|
4
|
+
if !defined? timezone
|
5
|
+
timezone = 'GMT'
|
6
|
+
end
|
7
|
+
|
8
|
+
image = 'fabric8/hawtio'
|
9
|
+
java_opts = ''
|
10
|
+
memory = 1024
|
11
|
+
cpu = 300
|
12
|
+
container_port = 0
|
13
|
+
service = lookup_service('hawtio', services)
|
14
|
+
if service
|
15
|
+
java_opts = service['JAVA_OPTS'] || java_opts
|
16
|
+
image = service['ContainerImage'] || image
|
17
|
+
memory = service['ContainerMemory'] || memory
|
18
|
+
cpu = service['ContainerCPU'] || cpu
|
19
|
+
container_port = service['InstancePort'] || container_port
|
20
|
+
end
|
21
|
+
|
22
|
+
CloudFormation {
|
23
|
+
|
24
|
+
AWSTemplateFormatVersion "2010-09-09"
|
25
|
+
Description "ciinabox - ECS Service Hawtio v#{ciinabox_version}"
|
26
|
+
|
27
|
+
Parameter("ECSCluster"){ Type 'String' }
|
28
|
+
Parameter("ECSRole"){ Type 'String' }
|
29
|
+
Parameter("ServiceELB"){ Type 'String' }
|
30
|
+
|
31
|
+
Resource('HawtioTask') {
|
32
|
+
Type "AWS::ECS::TaskDefinition"
|
33
|
+
Property('ContainerDefinitions', [
|
34
|
+
{
|
35
|
+
Name: 'hawtio',
|
36
|
+
Memory: memory,
|
37
|
+
Cpu: cpu,
|
38
|
+
Image: image,
|
39
|
+
Environment: [
|
40
|
+
{
|
41
|
+
Name: 'JAVA_OPTS',
|
42
|
+
Value: "#{java_opts} -Duser.timezone=#{timezone}"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
Name: 'VIRTUAL_HOST',
|
46
|
+
Value: "hawtio.#{dns_domain}"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
Name: 'VIRTUAL_PORT',
|
50
|
+
Value: '8080'
|
51
|
+
},
|
52
|
+
{
|
53
|
+
Name: 'hawtio_dirname',
|
54
|
+
Value: '/var/hawtio'
|
55
|
+
},
|
56
|
+
|
57
|
+
],
|
58
|
+
Essential: true,
|
59
|
+
MountPoints: [
|
60
|
+
{
|
61
|
+
ContainerPath: '/etc/localtime',
|
62
|
+
SourceVolume: 'timezone',
|
63
|
+
ReadOnly: true
|
64
|
+
},
|
65
|
+
{
|
66
|
+
ContainerPath: '/var/hawtio',
|
67
|
+
SourceVolume: 'data',
|
68
|
+
ReadOnly: false
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
])
|
73
|
+
Property('Volumes', [
|
74
|
+
{
|
75
|
+
Name: 'timezone',
|
76
|
+
Host: {
|
77
|
+
SourcePath: '/etc/localtime'
|
78
|
+
}
|
79
|
+
},
|
80
|
+
{
|
81
|
+
Name: 'data',
|
82
|
+
Host: {
|
83
|
+
SourcePath: '/data/hawtio'
|
84
|
+
}
|
85
|
+
}
|
86
|
+
])
|
87
|
+
}
|
88
|
+
|
89
|
+
Resource('HawtioService') {
|
90
|
+
Type 'AWS::ECS::Service'
|
91
|
+
Property('Cluster', Ref('ECSCluster'))
|
92
|
+
Property('DesiredCount', 1)
|
93
|
+
Property('TaskDefinition', Ref('HawtioTask'))
|
94
|
+
Property('Role', Ref('ECSRole')) unless container_port == 0
|
95
|
+
Property('LoadBalancers', [
|
96
|
+
{ ContainerName: 'hawtio', ContainerPort: container_port, LoadBalancerName: Ref('ServiceELB') }
|
97
|
+
]) unless container_port == 0
|
98
|
+
|
99
|
+
}
|
100
|
+
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'cfndsl'
|
2
|
+
require_relative '../../ext/helper'
|
3
|
+
|
4
|
+
if !defined? timezone
|
5
|
+
timezone = 'GMT'
|
6
|
+
end
|
7
|
+
|
8
|
+
#icinga2_image: AWS_ACCOUNT_ID.dkr.ecr.AWS_REGION/base2/icinga2:VERSION_TAG
|
9
|
+
image = "icinga/icinga2" #fail safe so file compiles
|
10
|
+
|
11
|
+
if defined? icinga2_image
|
12
|
+
image = icinga2_image
|
13
|
+
end
|
14
|
+
|
15
|
+
memory = 1024
|
16
|
+
cpu = 300
|
17
|
+
container_port = 0
|
18
|
+
|
19
|
+
CloudFormation {
|
20
|
+
|
21
|
+
AWSTemplateFormatVersion "2010-09-09"
|
22
|
+
Description "ciinabox - ECS Service Hawtio v#{ciinabox_version}"
|
23
|
+
|
24
|
+
Parameter("ECSCluster"){ Type 'String' }
|
25
|
+
Parameter("ECSRole"){ Type 'String' }
|
26
|
+
Parameter("ServiceELB"){ Type 'String' }
|
27
|
+
|
28
|
+
Resource('Icinga2Task') {
|
29
|
+
Type "AWS::ECS::TaskDefinition"
|
30
|
+
Property('ContainerDefinitions', [
|
31
|
+
{
|
32
|
+
Name: 'icinga2',
|
33
|
+
Memory: memory,
|
34
|
+
Cpu: cpu,
|
35
|
+
Image: image,
|
36
|
+
Environment: [
|
37
|
+
{
|
38
|
+
Name: 'VIRTUAL_HOST',
|
39
|
+
Value: "icinga2.#{dns_domain}"
|
40
|
+
},
|
41
|
+
{
|
42
|
+
Name: 'VIRTUAL_PORT',
|
43
|
+
Value: '80'
|
44
|
+
}
|
45
|
+
|
46
|
+
],
|
47
|
+
Essential: true,
|
48
|
+
MountPoints: [
|
49
|
+
{
|
50
|
+
ContainerPath: '/etc/localtime',
|
51
|
+
SourceVolume: 'timezone',
|
52
|
+
ReadOnly: true
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
])
|
57
|
+
Property('Volumes', [
|
58
|
+
{
|
59
|
+
Name: 'timezone',
|
60
|
+
Host: {
|
61
|
+
SourcePath: '/etc/localtime'
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
])
|
66
|
+
}
|
67
|
+
|
68
|
+
Resource('IcingaService') {
|
69
|
+
Type 'AWS::ECS::Service'
|
70
|
+
Property('Cluster', Ref('ECSCluster'))
|
71
|
+
Property('DesiredCount', 1)
|
72
|
+
Property('TaskDefinition', Ref('Icinga2Task'))
|
73
|
+
Property('Role', Ref('ECSRole')) unless container_port == 0
|
74
|
+
# Property('LoadBalancers', [
|
75
|
+
# { ContainerName: 'hawtio', ContainerPort: container_port, LoadBalancerName: Ref('ServiceELB') }
|
76
|
+
# ]) unless container_port == 0
|
77
|
+
|
78
|
+
}
|
79
|
+
}
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require 'cfndsl'
|
2
|
+
|
3
|
+
if !defined? timezone
|
4
|
+
timezone = 'GMT'
|
5
|
+
end
|
6
|
+
|
7
|
+
if !defined? internal_elb
|
8
|
+
internal_elb = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
if !defined? volatile_jenkins_slave
|
12
|
+
volatile_jenkins_slave = false
|
13
|
+
end
|
14
|
+
|
15
|
+
# Prefixing application images allows us to 'vendorize' ciinabox into client's account by setting
|
16
|
+
# ciinabox_repo to ${account_no}.dkr.ecr.${region}.amazonaws.com
|
17
|
+
if not defined? ciinabox_repo
|
18
|
+
ciinabox_repo=''
|
19
|
+
end
|
20
|
+
|
21
|
+
image = "#{ciinabox_repo}base2/ciinabox-jenkins:lts"
|
22
|
+
|
23
|
+
jenkins_java_opts = ''
|
24
|
+
memory = 2048
|
25
|
+
slave_memory = 2048
|
26
|
+
cpu = 300
|
27
|
+
container_port = 0
|
28
|
+
service = lookup_service('jenkins', services)
|
29
|
+
virtual_host = "jenkins.#{dns_domain}"
|
30
|
+
if defined? internal_elb and internal_elb
|
31
|
+
virtual_host = "#{virtual_host},internal-jenkins.#{dns_domain}"
|
32
|
+
end
|
33
|
+
port_mappings = []
|
34
|
+
|
35
|
+
if defined? service
|
36
|
+
service = {} if service.nil?
|
37
|
+
jenkins_java_opts = service['JAVA_OPTS'] || ''
|
38
|
+
image = service['ContainerImage'] || image
|
39
|
+
memory = service['ContainerMemory'] || 2048
|
40
|
+
slave_memory = service['SlaveContainerMemory'] || 2048
|
41
|
+
cpu = service['ContainerCPU'] || 300
|
42
|
+
|
43
|
+
if service['InstancePort']
|
44
|
+
port_mappings << {
|
45
|
+
HostPort: service['InstancePort'],
|
46
|
+
ContainerPort: service['InstancePort']
|
47
|
+
}
|
48
|
+
container_port = service['InstancePort']
|
49
|
+
virtual_host = "jenkins.#{dns_domain},internal-jenkins.#{dns_domain}"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# container volumes and container definitions depending on feature flags
|
55
|
+
volumes = [
|
56
|
+
{
|
57
|
+
Name: 'timezone',
|
58
|
+
Host: {
|
59
|
+
SourcePath: '/etc/localtime'
|
60
|
+
}
|
61
|
+
},
|
62
|
+
{
|
63
|
+
Name: 'jenkins_data',
|
64
|
+
Host: {
|
65
|
+
SourcePath: '/data/jenkins'
|
66
|
+
}
|
67
|
+
}]
|
68
|
+
|
69
|
+
container_definitions = [
|
70
|
+
{
|
71
|
+
Name: 'jenkins',
|
72
|
+
Links: [],
|
73
|
+
Memory: memory,
|
74
|
+
Cpu: cpu,
|
75
|
+
Image: image,
|
76
|
+
PortMappings: port_mappings,
|
77
|
+
Environment: [
|
78
|
+
{
|
79
|
+
Name: 'JAVA_OPTS',
|
80
|
+
Value: "#{jenkins_java_opts} -Duser.timezone=#{timezone}"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
Name: 'VIRTUAL_HOST',
|
84
|
+
Value: virtual_host
|
85
|
+
},
|
86
|
+
{
|
87
|
+
Name: 'VIRTUAL_PORT',
|
88
|
+
Value: '8080'
|
89
|
+
}
|
90
|
+
],
|
91
|
+
Essential: true,
|
92
|
+
MountPoints: [
|
93
|
+
{
|
94
|
+
ContainerPath: '/etc/localtime',
|
95
|
+
SourceVolume: 'timezone',
|
96
|
+
ReadOnly: true
|
97
|
+
},
|
98
|
+
{
|
99
|
+
ContainerPath: '/var/jenkins_home',
|
100
|
+
SourceVolume: 'jenkins_data',
|
101
|
+
ReadOnly: false
|
102
|
+
}
|
103
|
+
]
|
104
|
+
}
|
105
|
+
]
|
106
|
+
|
107
|
+
# If docker in docker slave is enabled
|
108
|
+
if defined? include_diind_slave and include_diind_slave
|
109
|
+
container_definitions[0][:Links] << 'jenkins-docker-dind-slave'
|
110
|
+
dind_definition = {
|
111
|
+
Name: 'jenkins-docker-dind-slave',
|
112
|
+
Memory: slave_memory,
|
113
|
+
Image: "#{ciinabox_repo}base2/ciinabox-docker-slave:#{docker_slave_version}",
|
114
|
+
Environment: [{Name: 'RUN_DOCKER_IN_DOCKER', Value: 1}],
|
115
|
+
Essential: false,
|
116
|
+
Privileged: true
|
117
|
+
}
|
118
|
+
dind_definition[:Environment] << { Name: 'USE_ECR_CREDENTIAL_HELPER', Value: 1 } if docker_slave_enable_ecr_credentials_helper
|
119
|
+
if not volatile_jenkins_slave
|
120
|
+
dind_definition[:MountPoints] = [
|
121
|
+
{
|
122
|
+
ContainerPath: '/var/lib/docker',
|
123
|
+
SourceVolume: 'jenkins_dind_data',
|
124
|
+
ReadOnly: false
|
125
|
+
}
|
126
|
+
]
|
127
|
+
volumes << {
|
128
|
+
Name: 'jenkins_dind_data',
|
129
|
+
Host: {
|
130
|
+
SourcePath: '/data/jenkins-diind'
|
131
|
+
}
|
132
|
+
}
|
133
|
+
end
|
134
|
+
container_definitions << dind_definition
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
# If docker outside of docker slave is enabled
|
139
|
+
if defined? include_dood_slave and include_dood_slave
|
140
|
+
container_definitions[0][:Links] << 'jenkins-docker-dood-slave'
|
141
|
+
dood_definition = {
|
142
|
+
Name: 'jenkins-docker-dood-slave',
|
143
|
+
Memory: slave_memory,
|
144
|
+
Image: "#{ciinabox_repo}base2/ciinabox-docker-slave:#{docker_slave_version}",
|
145
|
+
Environment: [{Name: 'RUN_DOCKER_IN_DOCKER', Value: 0}],
|
146
|
+
MountPoints: [
|
147
|
+
{
|
148
|
+
ContainerPath: '/var/run/docker.sock',
|
149
|
+
SourceVolume: 'docker_socket',
|
150
|
+
ReadOnly: false
|
151
|
+
},
|
152
|
+
{
|
153
|
+
ContainerPath: '/data/jenkins-dood',
|
154
|
+
SourceVolume: 'jenkins_dood_data',
|
155
|
+
ReadOnly: false
|
156
|
+
}
|
157
|
+
],
|
158
|
+
Essential: false,
|
159
|
+
Privileged: false
|
160
|
+
}
|
161
|
+
dood_definition[:Environment] << { Name: 'USE_ECR_CREDENTIAL_HELPER', Value: 1 } if docker_slave_enable_ecr_credentials_helper
|
162
|
+
container_definitions << dood_definition
|
163
|
+
volumes << {
|
164
|
+
Name: 'jenkins_dood_data',
|
165
|
+
Host: {
|
166
|
+
SourcePath: '/data/jenkins-dood'
|
167
|
+
}
|
168
|
+
}
|
169
|
+
volumes << {
|
170
|
+
Name: 'docker_socket',
|
171
|
+
Host: {
|
172
|
+
SourcePath: '/var/run/docker.sock'
|
173
|
+
}
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
CloudFormation {
|
179
|
+
|
180
|
+
AWSTemplateFormatVersion "2010-09-09"
|
181
|
+
Description "ciinabox - ECS Service Jenkins v#{ciinabox_version}"
|
182
|
+
|
183
|
+
Parameter("ECSCluster") {Type 'String'}
|
184
|
+
Parameter("ECSRole") {Type 'String'}
|
185
|
+
Parameter("ServiceELB") {Type 'String'}
|
186
|
+
Parameter('InternalELB') {Type 'String'} if internal_elb
|
187
|
+
|
188
|
+
Resource('JenkinsTask') {
|
189
|
+
Type "AWS::ECS::TaskDefinition"
|
190
|
+
Property('ContainerDefinitions', container_definitions)
|
191
|
+
Property('Volumes', volumes)
|
192
|
+
}
|
193
|
+
|
194
|
+
Resource('JenkinsService') {
|
195
|
+
Type 'AWS::ECS::Service'
|
196
|
+
Property('Cluster', Ref('ECSCluster'))
|
197
|
+
Property('DeploymentConfiguration', {
|
198
|
+
MaximumPercent: 100,
|
199
|
+
MinimumHealthyPercent: 0
|
200
|
+
})
|
201
|
+
Property('DesiredCount', 1)
|
202
|
+
Property('TaskDefinition', Ref('JenkinsTask'))
|
203
|
+
#For Role... Conditional. This parameter is required only if you specify the LoadBalancers property.
|
204
|
+
Property('Role', Ref('ECSRole')) if internal_elb and container_port != 0
|
205
|
+
Property('LoadBalancers', [
|
206
|
+
{ContainerName: 'jenkins', ContainerPort: container_port, LoadBalancerName: Ref('InternalELB')}
|
207
|
+
]) if internal_elb and container_port != 0
|
208
|
+
}
|
209
|
+
}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'cfndsl'
|
2
|
+
require_relative '../../ext/helper'
|
3
|
+
|
4
|
+
if !defined? timezone
|
5
|
+
timezone = 'GMT'
|
6
|
+
end
|
7
|
+
|
8
|
+
image = 'base2/ciinabox-nexus'
|
9
|
+
java_opts = ''
|
10
|
+
memory = 1024
|
11
|
+
cpu = 300
|
12
|
+
container_port = 0
|
13
|
+
service = lookup_service('nexus', services)
|
14
|
+
if service
|
15
|
+
java_opts = service['JAVA_OPTS'] || ''
|
16
|
+
image = service['ContainerImage'] || image
|
17
|
+
memory = service['ContainerMemory'] || 1024
|
18
|
+
cpu = service['ContainerCPU'] || 300
|
19
|
+
container_port = service['InstancePort'] || 0
|
20
|
+
end
|
21
|
+
|
22
|
+
CloudFormation {
|
23
|
+
|
24
|
+
AWSTemplateFormatVersion "2010-09-09"
|
25
|
+
Description "ciinabox - ECS Service Nexus v#{ciinabox_version}"
|
26
|
+
|
27
|
+
Parameter("ECSCluster"){ Type 'String' }
|
28
|
+
Parameter("ECSRole"){ Type 'String' }
|
29
|
+
Parameter("ServiceELB"){ Type 'String' }
|
30
|
+
|
31
|
+
Resource('NexusTask') {
|
32
|
+
Type "AWS::ECS::TaskDefinition"
|
33
|
+
Property('ContainerDefinitions', [
|
34
|
+
{
|
35
|
+
Name: 'nexus',
|
36
|
+
Memory: memory,
|
37
|
+
Cpu: cpu,
|
38
|
+
Image: image,
|
39
|
+
Environment: [
|
40
|
+
{
|
41
|
+
Name: 'JAVA_OPTS',
|
42
|
+
Value: "#{java_opts} -Duser.timezone=#{timezone} -server -Djava.net.preferIPv4Stack=true"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
Name: 'VIRTUAL_HOST',
|
46
|
+
Value: "nexus.#{dns_domain}"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
Name: 'VIRTUAL_PORT',
|
50
|
+
Value: '8081'
|
51
|
+
}
|
52
|
+
],
|
53
|
+
Essential: true,
|
54
|
+
MountPoints: [
|
55
|
+
{
|
56
|
+
ContainerPath: '/etc/localtime',
|
57
|
+
SourceVolume: 'timezone',
|
58
|
+
ReadOnly: true
|
59
|
+
},
|
60
|
+
{
|
61
|
+
ContainerPath: '/sonatype-work',
|
62
|
+
SourceVolume: 'nexus_data',
|
63
|
+
ReadOnly: false
|
64
|
+
}
|
65
|
+
]
|
66
|
+
}
|
67
|
+
])
|
68
|
+
Property('Volumes', [
|
69
|
+
{
|
70
|
+
Name: 'timezone',
|
71
|
+
Host: {
|
72
|
+
SourcePath: '/etc/localtime'
|
73
|
+
}
|
74
|
+
},
|
75
|
+
{
|
76
|
+
Name: 'nexus_data',
|
77
|
+
Host: {
|
78
|
+
SourcePath: '/data/nexus'
|
79
|
+
}
|
80
|
+
}
|
81
|
+
])
|
82
|
+
}
|
83
|
+
|
84
|
+
Resource('NexusService') {
|
85
|
+
Type 'AWS::ECS::Service'
|
86
|
+
Property('Cluster', Ref('ECSCluster'))
|
87
|
+
Property('DesiredCount', 1)
|
88
|
+
Property('TaskDefinition', Ref('NexusTask'))
|
89
|
+
Property('Role', Ref('ECSRole')) unless container_port == 0
|
90
|
+
Property('LoadBalancers', [
|
91
|
+
{ ContainerName: 'nexus', ContainerPort: container_port, LoadBalancerName: Ref('ServiceELB') }
|
92
|
+
]) unless container_port == 0
|
93
|
+
|
94
|
+
}
|
95
|
+
|
96
|
+
}
|