kite 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kite/core.rb +45 -28
  3. data/lib/kite/helpers.rb +7 -0
  4. data/lib/kite/version.rb +1 -1
  5. data/tpl/aws/bootstrap.sh +4 -7
  6. data/tpl/aws/{bin/make_manifest_bosh-init.sh → bosh/bosh_director.yml.erb} +22 -53
  7. data/tpl/aws/{bin/make_cloud_config.sh → concourse/aws_cloud.yml.erb} +3 -26
  8. data/tpl/aws/{bin/make_manifest_concourse-cluster.sh → concourse/concourse.yml.erb} +5 -20
  9. data/tpl/aws/terraform/main.tf +37 -0
  10. data/tpl/aws/terraform/network.tf +177 -0
  11. data/tpl/aws/terraform/outputs.tf +5 -5
  12. data/tpl/aws/terraform/terraform.tfvars.erb +18 -7
  13. data/tpl/aws/terraform/variables.tf +52 -18
  14. data/tpl/gcp/bosh-install.sh.erb +18 -0
  15. data/tpl/gcp/terraform/main.tf +56 -0
  16. data/tpl/gcp/terraform/network.tf +30 -0
  17. data/tpl/gcp/terraform/outputs.tf +3 -0
  18. data/tpl/gcp/terraform/terraform.tfvars.erb +14 -0
  19. data/tpl/gcp/terraform/variables.tf +32 -0
  20. data/tpl/skel/config/cloud.yml +22 -20
  21. metadata +13 -24
  22. data/tpl/aws/env.example.erb +0 -12
  23. data/tpl/aws/terraform/aws-concourse.tf +0 -127
  24. data/tpl/aws/terraform/aws-vault.tf +0 -26
  25. data/tpl/aws/terraform/bosh-aws-base.tf +0 -118
  26. data/tpl/gcp/INSTALL.md +0 -25
  27. data/tpl/gcp/README.md +0 -377
  28. data/tpl/gcp/cloud-config.yml.erb +0 -66
  29. data/tpl/gcp/concourse.tf +0 -62
  30. data/tpl/gcp/concourse.yml.erb +0 -101
  31. data/tpl/gcp/env.example.erb +0 -7
  32. data/tpl/gcp/main.tf +0 -107
  33. data/tpl/gcp/manifest.yml.erb +0 -173
  34. data/tpl/gcp/scripts/01_create_infrastructure.sh +0 -24
  35. data/tpl/gcp/scripts/02_deploy_director.sh +0 -35
  36. data/tpl/gcp/scripts/03_deploy_concourse.sh +0 -29
  37. data/tpl/gcp/scripts/04_delete_director.sh +0 -6
  38. data/tpl/gcp/scripts/05_delete_infrastructure.sh +0 -23
  39. data/tpl/gcp/scripts/bootstrap.sh +0 -22
  40. data/tpl/gcp/scripts/delete.sh +0 -16
@@ -1,15 +1,15 @@
1
1
  output "security_group_id" {
2
- value = "${aws_security_group.boshdefault.id}"
2
+ value = "${aws_security_group.bosh_sg.id}"
3
3
  }
4
4
 
5
- output "default_subnet_id" {
6
- value = "${aws_subnet.default.id}"
5
+ output "platform_subnet_id" {
6
+ value = "${aws_subnet.platform.id}"
7
7
  }
8
8
 
9
9
  output "ops_services_subnet_id" {
10
10
  value = "${aws_subnet.ops_services.id}"
11
11
  }
12
12
 
13
- output "eip" {
14
- value = "${aws_eip.boshdirector.public_ip}"
13
+ output "bastion_ip" {
14
+ value = "${aws_instance.bastion.public_ip}"
15
15
  }
@@ -1,7 +1,18 @@
1
- aws_access_key_id="<%= @values['aws']['access_key_id'] %>"
2
- aws_secret_access_key="<%= @values['aws']['secret_access_key'] %>"
3
- aws_region="<%= @values['aws']['region'] %>"
4
- aws_availability_zone="<%= @values['aws']['az'] %>"
5
- //ssl_cert_arn="arn:aws:iam::12345"
6
- ci_dns_zone_id="<%= @values['aws']['ci_dns_zone_id'] %>"
7
- ci_hostname="<%= @values['aws']['ci_hostname'] %>"
1
+ # Credentials
2
+ aws_access_key = "<%= @values['aws']['access_key'] %>"
3
+ aws_secret_key = "<%= @values['aws']['secret_key'] %>"
4
+ aws_region = "<%= @values['aws']['region'] %>"
5
+ aws_availability_zone = "<%= @values['aws']['az'] %>"
6
+
7
+ # Network Config
8
+ aws_vpc_cidr_block = "<%= @values['aws']['vpc_cidr_block'] %>"
9
+ aws_vpc_name = "<%= @values['aws']['vpc_name'] %>"
10
+ aws_platform_subnet_cidr_block = "<%= @values['aws']['platform_subnet_cidr_block'] %>"
11
+ aws_platform_subnet_name = "<%= @values['aws']['platform_subnet_name'] %>"
12
+ aws_ops_subnet_cidr_block = "<%= @values['aws']['ops_subnet_cidr_block'] %>"
13
+ aws_ops_subnet_name = "<%= @values['aws']['ops_subnet_name'] %>"
14
+
15
+ # Kite config
16
+ keypair_name = "<%= @values['kite']['keypair_name'] %>"
17
+ public_key = "<%= @values['kite']['public_key_path'] %>"
18
+ private_key = "<%= @values['kite']['private_key_path'] %>"
@@ -1,26 +1,60 @@
1
- variable "aws_access_key_id" {
2
- type = "string"
1
+ variable "aws_access_key" {
2
+ type = "string"
3
3
  }
4
- variable "aws_secret_access_key" {
5
- type = "string"
4
+
5
+ variable "aws_secret_key" {
6
+ type = "string"
6
7
  }
8
+
9
+ variable "public_key" {
10
+ type = "string"
11
+ }
12
+
13
+ variable "private_key" {
14
+ type = "string"
15
+ }
16
+
17
+ variable "keypair_name" {
18
+ type = "string"
19
+ }
20
+
7
21
  variable "aws_region" {
8
- type = "string"
9
- default = "us-east-1"
22
+ type = "string"
23
+ default = "eu-central-1"
10
24
  }
25
+
11
26
  variable "aws_availability_zone" {
12
- type = "string"
13
- default = "us-east-1a"
27
+ type = "string"
28
+ default = "eu-central-1a"
29
+ }
30
+
31
+ variable "aws_vpc_cidr_block" {
32
+ type = "string"
33
+ }
34
+
35
+ variable "aws_vpc_name" {
36
+ type = "string"
37
+ }
38
+
39
+ variable "aws_platform_subnet_cidr_block" {
40
+ type = "string"
41
+ }
42
+
43
+ variable "aws_platform_subnet_name" {
44
+ type = "string"
45
+ }
46
+
47
+ variable "aws_ops_subnet_cidr_block" {
48
+ type = "string"
14
49
  }
15
- //variable "source_access_block1" {
16
- //type = "string"
17
- //}
18
- variable "ci_hostname" {
19
- type = "string"
50
+
51
+ variable "aws_ops_subnet_name" {
52
+ type = "string"
20
53
  }
21
- variable "ci_dns_zone_id" {
22
- type = "string"
54
+
55
+ variable "aws_amis" {
56
+ default = {
57
+ us-east-1 = "ami-1d4e7a66"
58
+ eu-central-1 = "ami-958128fa"
59
+ }
23
60
  }
24
- //variable "ssl_cert_arn" {
25
- //type = "string"
26
- //}
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -xe
4
+
5
+ bosh create-env bosh-deployment/bosh.yml \
6
+ --state=config/state.json \
7
+ --vars-store=config/creds.yml \
8
+ -o bosh-deployment/gcp/cpi.yml \
9
+ -v director_name=bosh-director \
10
+ -v internal_cidr=<%= @values['gcp']['subnet_cidr'] %> \
11
+ -v internal_gw=<%= @values['gcp']['internal_gw'] %> \
12
+ -v internal_ip=<%= @values['bosh']['static_ip'] %> \
13
+ --var-file gcp_credentials_json=<%= @values['gcp']['service_account'] %> \
14
+ -v project_id=<%= @values['gcp']['project'] %> \
15
+ -v zone=<%= @values['gcp']['zone'] %> \
16
+ -v tags=[platform-internal] \
17
+ -v network=<%= @values['gcp']['vpc_name'] %> \
18
+ -v subnetwork=<%= @values['gcp']['subnet_name'] %>
@@ -0,0 +1,56 @@
1
+ provider "google" {
2
+ credentials = "${file("${var.credentials}")}"
3
+ project = "${var.project}"
4
+ region = "${var.region}"
5
+ }
6
+
7
+ # Allow SSH to Platform Bastion
8
+ resource "google_compute_firewall" "bastion" {
9
+ name = "bastion-rules"
10
+ network = "${google_compute_network.platform.name}"
11
+
12
+ allow {
13
+ protocol = "icmp"
14
+ }
15
+
16
+ allow {
17
+ protocol = "tcp"
18
+ ports = ["22"]
19
+ }
20
+
21
+ target_tags = ["bastion"]
22
+ }
23
+
24
+ # Bastion host
25
+ resource "google_compute_address" "bastion" {
26
+ name = "bastion-ip"
27
+ }
28
+
29
+ resource "google_compute_instance" "bastion" {
30
+ name = "bastion"
31
+ machine_type = "n1-standard-1"
32
+ zone = "${var.zone}"
33
+
34
+ tags = ["bastion", "platform-internal"]
35
+
36
+ boot_disk {
37
+ initialize_params {
38
+ image = "debian-cloud/debian-8"
39
+ }
40
+ }
41
+
42
+ metadata {
43
+ sshKeys = "kite:${file(var.public_key)}"
44
+ }
45
+
46
+ network_interface {
47
+ subnetwork = "${google_compute_subnetwork.platform_net.name}"
48
+ access_config {
49
+ nat_ip = "${google_compute_address.bastion.address}"
50
+ }
51
+ }
52
+
53
+ service_account {
54
+ scopes = ["userinfo-email", "compute-ro", "storage-ro"]
55
+ }
56
+ }
@@ -0,0 +1,30 @@
1
+ resource "google_compute_network" "platform" {
2
+ name = "${var.vpc_name}"
3
+ }
4
+
5
+ # Subnet for the Platform tools
6
+ resource "google_compute_subnetwork" "platform_net" {
7
+ name = "platform-net"
8
+ ip_cidr_range = "${var.subnet_cidr}"
9
+ network = "${google_compute_network.platform.self_link}"
10
+ }
11
+
12
+ # Allow open access between internal VM
13
+ resource "google_compute_firewall" "platform_internal" {
14
+ name = "platform-internal"
15
+ network = "${google_compute_network.platform.name}"
16
+
17
+ allow {
18
+ protocol = "icmp"
19
+ }
20
+
21
+ allow {
22
+ protocol = "tcp"
23
+ }
24
+
25
+ allow {
26
+ protocol = "udp"
27
+ }
28
+ target_tags = ["platform-internal"]
29
+ source_tags = ["platform-internal"]
30
+ }
@@ -0,0 +1,3 @@
1
+ output "bastion_ip" {
2
+ value = "${google_compute_address.bastion.address}"
3
+ }
@@ -0,0 +1,14 @@
1
+ # Kite config
2
+ keypair_name = "<%= @values['kite']['keypair_name'] %>"
3
+ public_key = "<%= @values['kite']['public_key_path'] %>"
4
+ private_key = "<%= @values['kite']['private_key_path'] %>"
5
+
6
+ # Credentials
7
+ credentials = "<%= @values['gcp']['service_account'] %>"
8
+ project = "<%= @values['gcp']['project'] %>"
9
+ region = "<%= @values['gcp']['region'] %>"
10
+ zone = "<%= @values['gcp']['zone'] %>"
11
+
12
+ # Network Config
13
+ vpc_name = "<%= @values['gcp']['vpc_name'] %>"
14
+ subnet_cidr = "<%= @values['gcp']['subnet_cidr'] %>"
@@ -0,0 +1,32 @@
1
+
2
+ variable "project" {
3
+ type = "string"
4
+ }
5
+
6
+ variable "region" {
7
+ type = "string"
8
+ default = "us-east1"
9
+ }
10
+
11
+ variable "zone" {
12
+ type = "string"
13
+ default = "us-east1-d"
14
+ }
15
+
16
+ variable "credentials" {
17
+ type = "string"
18
+ }
19
+
20
+ variable "vpc_name" {
21
+ type = "string"
22
+ default = "platform-tools"
23
+ }
24
+
25
+ variable "subnet_cidr" {
26
+ type = "string"
27
+ default = "10.0.0.0/24"
28
+ }
29
+
30
+ variable "public_key" {
31
+ type = "string"
32
+ }
@@ -1,34 +1,36 @@
1
+ kite:
2
+ keypair_name: "kitekey"
3
+ public_key_path: "~/.ssh/kite.key.pub"
4
+ private_key_path: "~/.ssh/kite.key"
5
+
1
6
  aws:
2
- access_key_id: "XXXXXXXXXXXXXX"
3
- secret_access_key: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
4
- region: "us-east-1"
5
- az: "us-east-1a"
6
- bosh_password: "bosh_password"
7
- keypair_name: "bosh"
8
- private_key_path: "~/Downloads/bosh.pem"
9
- db_password: "database_password"
10
- ci_dns_zone_id: "XXXXXXXXXXXXX"
11
- ci_hostname: "ci.example.com"
12
- concourse_url: "http://ci.example.com"
13
- concourse_auth_username: "concourse"
14
- concourse_auth_password: "concourse"
7
+ access_key: "enter your amazon key"
8
+ secret_key: "enter your secret key"
9
+ region: "eu-central-1"
10
+ az: "eu-central-1a"
11
+ vpc_cidr_block: "10.0.0.0/16"
12
+ vpc_name: "platform-tools"
13
+ platform_subnet_cidr_block: "10.0.0.0/24"
14
+ platform_subnet_name: "platform_net"
15
+ ops_subnet_cidr_block: "10.0.10.0/24"
16
+ ops_subnet_name: "ops_services"
15
17
 
16
18
  gcp:
17
19
  project_id: gcp-project
18
20
  region: europe-west1
19
21
  zone: europe-west1-b
20
- service_account: bosh
21
- ssh_key_path: ~/.ssh/bosh
22
+ service_account: "~/safe/terraform.json"
23
+ vpc_name: "platform-tools"
24
+ subnet_name: "platform-net"
25
+ subnet_cidr: "10.0.0.0/24"
26
+ internal_gw: "10.0.0.1"
22
27
 
23
28
  bosh:
24
- bosh_password: "bosh_password"
25
- keypair_name: "bosh"
26
- private_key_path: "~/Downloads/bosh.pem"
27
- db_password: "database_password"
29
+ static_ip: "10.0.0.10"
28
30
 
29
31
  concourse:
30
32
  hostname: "ci.domain.io"
31
- dns_zone: "your_dns_zone_id"
32
33
  url: "http://ci.example.com"
33
34
  auth_username: "concourse"
34
35
  auth_password: "concourse"
36
+ db_password: "changeme"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis Bellet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2017-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -93,32 +93,21 @@ files:
93
93
  - lib/kite/helpers.rb
94
94
  - lib/kite/version.rb
95
95
  - tpl/aws/README.md
96
- - tpl/aws/bin/make_cloud_config.sh
97
- - tpl/aws/bin/make_manifest_bosh-init.sh
98
- - tpl/aws/bin/make_manifest_concourse-cluster.sh
99
96
  - tpl/aws/bootstrap.sh
100
- - tpl/aws/env.example.erb
101
- - tpl/aws/terraform/aws-concourse.tf
102
- - tpl/aws/terraform/aws-vault.tf
103
- - tpl/aws/terraform/bosh-aws-base.tf
97
+ - tpl/aws/bosh/bosh_director.yml.erb
98
+ - tpl/aws/concourse/aws_cloud.yml.erb
99
+ - tpl/aws/concourse/concourse.yml.erb
100
+ - tpl/aws/terraform/main.tf
101
+ - tpl/aws/terraform/network.tf
104
102
  - tpl/aws/terraform/outputs.tf
105
103
  - tpl/aws/terraform/terraform.tfvars.erb
106
104
  - tpl/aws/terraform/variables.tf
107
- - tpl/gcp/INSTALL.md
108
- - tpl/gcp/README.md
109
- - tpl/gcp/cloud-config.yml.erb
110
- - tpl/gcp/concourse.tf
111
- - tpl/gcp/concourse.yml.erb
112
- - tpl/gcp/env.example.erb
113
- - tpl/gcp/main.tf
114
- - tpl/gcp/manifest.yml.erb
115
- - tpl/gcp/scripts/01_create_infrastructure.sh
116
- - tpl/gcp/scripts/02_deploy_director.sh
117
- - tpl/gcp/scripts/03_deploy_concourse.sh
118
- - tpl/gcp/scripts/04_delete_director.sh
119
- - tpl/gcp/scripts/05_delete_infrastructure.sh
120
- - tpl/gcp/scripts/bootstrap.sh
121
- - tpl/gcp/scripts/delete.sh
105
+ - tpl/gcp/bosh-install.sh.erb
106
+ - tpl/gcp/terraform/main.tf
107
+ - tpl/gcp/terraform/network.tf
108
+ - tpl/gcp/terraform/outputs.tf
109
+ - tpl/gcp/terraform/terraform.tfvars.erb
110
+ - tpl/gcp/terraform/variables.tf
122
111
  - tpl/skel/Gemfile.tt
123
112
  - tpl/skel/README.md.tt
124
113
  - tpl/skel/bin/kite
@@ -1,12 +0,0 @@
1
- export AWS_ACCESS_KEY_ID=<%= @values['aws']['access_key_id'] %>
2
- export AWS_SECRET_ACCESS_KEY=<%= @values['aws']['secret_access_key'] %>
3
- export AWS_REGION=<%= @values['aws']['region'] %>
4
- export AWS_AZ=<%= @values['aws']['az'] %>
5
- export BOSH_PASSWORD=<%= @values['aws']['bosh_password'] %>
6
- export AWS_KEYPAIR_KEY_NAME=<%= @values['aws']['keypair_name'] %>
7
- export PRIVATE_KEY_PATH=<%= @values['aws']['private_key_path'] %>
8
-
9
- export DB_PASSWORD=<%= @values['aws']['db_password'] %>
10
- export CONCOURSE_URL=<%= @values['aws']['concourse_url'] %>
11
- export CONCOURSE_AUTH_USERNAME=<%= @values['aws']['concourse_auth_username'] %>
12
- export CONCOURSE_AUTH_PASSWORD=<%= @values['aws']['concourse_auth_password'] %>
@@ -1,127 +0,0 @@
1
- # Create a Concourse security group
2
- resource "aws_security_group" "concourse-sg" {
3
- name = "concourse-sg"
4
- description = "Concourse security group"
5
- vpc_id = "${aws_vpc.default.id}"
6
- tags {
7
- Name = "concourse-sg"
8
- component = "concourse"
9
- }
10
-
11
- # outbound internet access
12
- egress {
13
- from_port = 0
14
- to_port = 0
15
- protocol = "-1"
16
- cidr_blocks = ["0.0.0.0/0"]
17
- }
18
-
19
- # inbound connections from ELB
20
- ingress {
21
- from_port = 8080
22
- to_port = 8080
23
- protocol = "tcp"
24
- security_groups = ["${aws_security_group.elb-sg.id}"]
25
- }
26
-
27
- ingress {
28
- from_port = 8080
29
- to_port = 8080
30
- protocol = "tcp"
31
- cidr_blocks = [
32
- "0.0.0.0/0"]
33
- }
34
-
35
- ingress {
36
- from_port = 2222
37
- to_port = 2222
38
- protocol = "tcp"
39
- security_groups = ["${aws_security_group.elb-sg.id}"]
40
- }
41
- }
42
-
43
- # Create an ELB security group
44
- resource "aws_security_group" "elb-sg" {
45
- name = "elb-sg"
46
- description = "ELB security group"
47
- vpc_id = "${aws_vpc.default.id}"
48
- tags {
49
- Name = "elb-sg"
50
- component = "concourse"
51
- }
52
-
53
- # outbound internet access
54
- egress {
55
- from_port = 0
56
- to_port = 0
57
- protocol = "-1"
58
- cidr_blocks = ["0.0.0.0/0"]
59
- }
60
-
61
- # inbound http
62
- ingress {
63
- from_port = 80
64
- to_port = 80
65
- protocol = "tcp"
66
- cidr_blocks = ["0.0.0.0/0"]
67
- }
68
-
69
- # inbound https
70
- ingress {
71
- from_port = 443
72
- to_port = 443
73
- protocol = "tcp"
74
- cidr_blocks = ["0.0.0.0/0"]
75
- }
76
-
77
- # inbound https
78
- ingress {
79
- from_port = 2222
80
- to_port = 2222
81
- protocol = "tcp"
82
- cidr_blocks = ["0.0.0.0/0"]
83
- }
84
-
85
- }
86
-
87
- # Create a new load balancer
88
- resource "aws_elb" "concourse" {
89
- name = "concourse-elb"
90
- subnets = ["${aws_subnet.ops_services.id}"]
91
- security_groups = ["${aws_security_group.elb-sg.id}"]
92
-
93
- listener {
94
- instance_port = 8080
95
- instance_protocol = "http"
96
- lb_port = 80
97
- lb_protocol = "http"
98
- }
99
-
100
- listener {
101
- instance_port = 8080
102
- instance_protocol = "http"
103
- lb_port = 80
104
- lb_protocol = "http"
105
- // ssl_certificate_id = "${var.ssl_cert_arn}"
106
- }
107
-
108
- listener {
109
- instance_port = 2222
110
- instance_protocol = "tcp"
111
- lb_port = 2222
112
- lb_protocol = "tcp"
113
- }
114
-
115
- tags {
116
- component = "concourse"
117
- }
118
- }
119
-
120
- # Create a CNAME record
121
- resource "aws_route53_record" "concourse" {
122
- zone_id = "${var.ci_dns_zone_id}"
123
- name = "${var.ci_hostname}"
124
- type = "CNAME"
125
- ttl = "300"
126
- records = ["${aws_elb.concourse.dns_name}"]
127
- }