Skip to content

Commit

Permalink
Fix Terraform/Ansible docs (apache#1290)
Browse files Browse the repository at this point in the history
* remove separate BK systemd service

* add tfvars file, reformat terraform configs, and update docs

* update docs with --user=ec2-user flag

* fix jq command in docs

* update pulsar version in ansible playbook config

* revert changes to .service files

* revert ansible config
  • Loading branch information
lucperkins authored and merlimat committed Feb 27, 2018
1 parent 9656c06 commit 3739567
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ generated-site/

# Ansible and Terraform artifacts
deployment/terraform-ansible/deploy-pulsar.retry
deployment/terraform-ansible/aws/terraform*
deployment/terraform-ansible/aws/.terraform/
deployment/terraform-ansible/aws/.terraform.tfstate.lock.info
deployment/terraform-ansible/aws/terraform.tfstate
deployment/terraform-ansible/aws/terraform.tfstate.backup
3 changes: 1 addition & 2 deletions deployment/terraform-ansible/aws/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
#

[defaults]
private_key_file=~/.ssh/pulsar_aws
private_key_file=~/.ssh/id_rsa
host_key_checking=false
user='ec2-user'

[privilege_escalation]
become=True
Expand Down
12 changes: 6 additions & 6 deletions deployment/terraform-ansible/aws/instances.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ resource "aws_instance" "zookeeper" {
}

resource "aws_instance" "pulsar" {
ami = "${var.aws_ami}"
instance_type = "${var.instance_types["pulsar"]}"
key_name = "${aws_key_pair.default.id}"
subnet_id = "${aws_subnet.default.id}"
vpc_security_group_ids = ["${aws_security_group.default.id}"]
count = "${var.num_pulsar_brokers}"
ami = "${var.aws_ami}"
instance_type = "${var.instance_types["pulsar"]}"
key_name = "${aws_key_pair.default.id}"
subnet_id = "${aws_subnet.default.id}"
vpc_security_group_ids = ["${aws_security_group.default.id}"]
count = "${var.num_pulsar_brokers}"

tags {
Name = "pulsar-${count.index + 1}"
Expand Down
2 changes: 1 addition & 1 deletion deployment/terraform-ansible/aws/keys.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ resource "random_id" "key_pair_name" {
resource "aws_key_pair" "default" {
key_name = "${random_id.key_pair_name.hex}"
public_key = "${file(var.public_key_path)}"
}
}
12 changes: 6 additions & 6 deletions deployment/terraform-ansible/aws/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ resource "aws_route_table_association" "default" {

/* Misc */
resource "aws_eip" "default" {
vpc = true
vpc = true
depends_on = ["aws_internet_gateway.default"]
}

Expand Down Expand Up @@ -90,10 +90,10 @@ resource "aws_route" "internet_access" {

/* Load balancer */
resource "aws_elb" "default" {
name = "pulsar-elb"
instances = ["${aws_instance.pulsar.*.id}"]
security_groups = ["${aws_security_group.elb.id}"]
subnets = ["${aws_subnet.default.id}"]
name = "pulsar-elb"
instances = ["${aws_instance.pulsar.*.id}"]
security_groups = ["${aws_security_group.elb.id}"]
subnets = ["${aws_subnet.default.id}"]

listener {
instance_port = 8080
Expand All @@ -114,4 +114,4 @@ resource "aws_elb" "default" {
tags {
Name = "Pulsar-Load-Balancer"
}
}
}
2 changes: 1 addition & 1 deletion deployment/terraform-ansible/aws/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ output "pulsar_web_url" {

output "pulsar_ssh_host" {
value = "${aws_instance.pulsar.0.public_ip}"
}
}
2 changes: 1 addition & 1 deletion deployment/terraform-ansible/aws/security.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ resource "aws_security_group" "default" {
tags {
Name = "Pulsar-Security-Group"
}
}
}
12 changes: 12 additions & 0 deletions deployment/terraform-ansible/aws/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public_key_path = "~/.ssh/id_rsa.pub"
region = "us-west-2"
availability_zone = "us-west-2a"
aws_ami = "ami-9fa343e7"
num_zookeeper_nodes = 3
num_pulsar_brokers = 3
base_cidr_block = "10.0.0.0/16"

instance_types = {
"pulsar" = "i3.xlarge"
"zookeeper" = "t2.small"
}
2 changes: 1 addition & 1 deletion deployment/terraform-ansible/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ variable "instance_types" {

variable "base_cidr_block" {
description = "The baseline CIDR block to be used by network assets for the Pulsar cluster"
}
}
8 changes: 5 additions & 3 deletions site/docs/latest/deployment/aws-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ Variable name | Description | Default
`public_key_path` | The path of the public key that you've generated. | `~/.ssh/id_rsa.pub`
`region` | The AWS region in which the Pulsar cluster will run | `us-west-2`
`availability_zone` | The AWS availability zone in which the Pulsar cluster will run | `us-west-2a`
`ami` | The [Amazon Machine Image](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) (AMI) that will be used by the cluster | `ami-9fa343e7`
`aws_ami` | The [Amazon Machine Image](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html) (AMI) that will be used by the cluster | `ami-9fa343e7`
`num_zookeeper_nodes` | The number of [ZooKeeper](https://zookeeper.apache.org) nodes in the ZooKeeper cluster | 3
`num_pulsar_brokers` | The number of Pulsar brokers and BookKeeper bookies that will run in the cluster | 3
`base_cidr_block` | The root [CIDR](http://searchnetworking.techtarget.com/definition/CIDR) that will be used by network assets for the cluster | `10.0.0.0/16`
`instance_types` | The EC2 instance types to be used. This variable is a map with two keys: `zookeeper` for the ZooKeeper instances and `pulsar` for the Pulsar brokers and BookKeeper bookies | `t2.small` (ZooKeeper) and `i3.3xlarge` (Pulsar/BookKeeper)
`instance_types` | The EC2 instance types to be used. This variable is a map with two keys: `zookeeper` for the ZooKeeper instances and `pulsar` for the Pulsar brokers and BookKeeper bookies | `t2.small` (ZooKeeper) and `i3.xlarge` (Pulsar/BookKeeper)

### What is installed

Expand Down Expand Up @@ -122,7 +122,7 @@ pulsar://pulsar-elb-1800761694.us-west-2.elb.amazonaws.com:6650
You can fetch that value at any time by running `terraform output pulsar_service_url` or parsing the `terraform.tstate` file (which is JSON, even though the filename doesn't reflect that):

```bash
$ cat terraform.tfstate | jq '.modules | .[0].outputs.pulsar_connection_url.value'
$ cat terraform.tfstate | jq .modules[0].outputs.pulsar_service_url.value
```

### Destroying your cluster
Expand All @@ -139,6 +139,7 @@ Once you've created the necessary AWS resources using Terraform, you can install

```bash
$ ansible-playbook \
--user='ec2-user' \
--inventory=`which terraform-inventory` \
../deploy-pulsar.yaml
```
Expand All @@ -147,6 +148,7 @@ If you've created a private SSH key at a location different from `~/.ssh/id_rsa`

```bash
$ ansible-playbook \
--user='ec2-user' \
--inventory=`which terraform-inventory` \
--private-key="~/.ssh/some-non-default-key" \
../deploy-pulsar.yaml
Expand Down

0 comments on commit 3739567

Please sign in to comment.