'How to start a process (or Kafka to be specific) on remote host with Ansible Playbook
How to start Zookeeper and Kafka broker on remote target with Ansible Playbook.
Following commands work fine locally.
Start Zookeeper:
cd /opt/kafka
./bin/zookeeper-server-start.sh config/zookeeper.properties
Start Kafka Broker: (setting 2 env variables while starting)
JMX_PORT="5555" KAFKA_HEAP_OPTS="-Xms500M -Xmx550M" ./bin/kafka-server-start.sh config/server.properties
Solution 1:[1]
I'd recommend creating a systemd service file that you can start/stop appropriately using the Ansible service
module.
Confluent offers cp-ansible
repo that you can either copy from, or use directly to install a Kafka + Zookeeper cluster (and more)
Solution 2:[2]
You can use either the modules shell, command
Using command, I think something like that should work:
- name: Start Zookeeper
command:
cmd: ./bin/zookeeper-server-start.sh config/zookeeper.properties
chdir: /opt/kafka
- name: Start Kafka broker
command:
cmd: 'JMX_PORT="5555" KAFKA_HEAP_OPTS="-Xms500M -Xmx550M" ./bin/kafka-server-start.sh config/server.properties'
chdir: /opt/kafka
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | OneCricketeer |
Solution 2 |