git clone [email protected]:cricket007/cp-ansible-vagrant.git
cd cp-ansible-vagrant
git submodule init && git submodule update --remote
Using Vagrant to get up and running.
- Install VirtualBox https://www.virtualbox.org/
- Install Vagrant http://www.vagrantup.com/
- Vagrant plugins
vagrant plugin install vagrant-hostmanager vagrant-vbguest
# Optional
vagrant plugin install vagrant-cachier # Caches & shares package downloads across VMs
Several profiles have already been defined in the profiles/
directory.
By default, kafka-1
will be started. You can override this behavior by exporting the CP_PROFILE
variable prior to starting Vagrant. This variable does not persist and will need re-defined for each new terminal session.
All profiles have at least one broker and one zookeeper unless otherwise mentioned.
Profile | Description |
---|---|
kafka-1 |
|
kafka-cluster-3 |
|
kafka-registry-ksql-1 |
|
kafka-registry-connect-1 |
|
kafka-registry-connect-ksql-1 |
|
kafka-registry-connect-ksql-c3-1 |
Requires at least 16 GB RAM
|
kafka-rest-1 |
|
kafka-sslCA-1 |
|
kafka-tools-1 |
|
Example running a different profile
export CP_PROFILE=kafka-registry-connect-1
vagrant up
New profiles can be added following the YAML format of the other profiles. If not specified, the default memory is 1536
(MB) and default CPU is 1
. If a port value mapping is not specified, it'll create a direct port forward to the host for the given key. The vars
key will be assigned to the Ansible host variables.
By default, this starts up a bento/centos-7
Vagrant box with PLAINTEXT
security between all services.
vagrant up
To use a different OS, set the VAGRANT_BOX
variable. For example, to start Ubuntu 16.04
VAGRANT_BOX=ubuntu/xenial64 vagrant up
To set a different security mode, find the sibling folders next to roles/
in the parent directory that contain an all.yml
and set the name of that directory to the CP_SECURITY_MODE
variable. For example, to use the sasl_ssl/all.yml
playbook file
CP_SECURITY_MODE=sasl_ssl vagrant up
To log into one of the machines:
vagrant ssh <machineName>
If you need to update the running cluster, you can re-run the provisioner (the step that installs software and configures services):
vagrant provision
By default, all services are provisioned according to their machine groups and targets defined in the all.yml
file for the chosen security mode playbook.
The ANSIBLE_LIMIT
variable can be used override this behavior to target specific machines. Its syntax matches the --limit
flag or host pattern options of ansible
and ansible-playbook
commands.
Group names can be found in the Ansible playbook directory set by CP_SECURITY_MODE
. For example, if we wanted to re-provision all the Kafka brokers:
ANSIBLE_LIMIT=broker vagrant provision
The machines are labelled in the profiles/
directory. If we wanted to re-provision two machines in the zookeeper
group, zk0
and zk1
:
ANSIBLE_LIMIT='zk[01]' vagrant provision
If there is a change in the CP_PROFILE
variable that uses different hostnames for the machines, or once we are done with the Vagrant environment, we can cleanup the cluster by destroying all VMs:
vagrant destroy -f