Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inventory file #27

Open
cloudman1978 opened this issue Nov 29, 2021 · 2 comments
Open

inventory file #27

cloudman1978 opened this issue Nov 29, 2021 · 2 comments

Comments

@cloudman1978
Copy link

First of all, thank you for this great resource.
I world like to have an example of inventory file to get zookeeper working fine.
I installed zookeeper with a file I did myself. All worked fine , however all nodes are in standalone mode.
thanks in advance

@sleighzy
Copy link
Owner

Hi. Glad to hear it's helping you.

Are you able to provide me with what your inventory file looks like? You may be experiencing a similar problem to #26 whereby if the zookeeper_id isn't provided for each node then it won't configure the cluster correctly.

One example of an inventory file, in ini format, is below:

zoo1 ansible_host=192.168.1.101
zoo2 ansible_host=192.168.1.102
zoo3 ansible_host=192.168.1.103

[zookeeper-nodes]
zoo1 zookeeper_id=1
zoo2 zookeeper_id=2
zoo3 zookeeper_id=3

I have seen other examples, e.g. https://github.com/AnsibleShipyard/ansible-zookeeper/blob/master/templates/myid.j2 and https://github.com/AnsibleShipyard/ansible-zookeeper/blob/master/templates/zoo.cfg.j2, where people have used the loop index of the hosts to specify the zookeeper id (there are more simple examples out there as well). Those examples remove the need for specifying zookeeper_id in the inventory, but this could lead to different ids being used and the myid changing on servers if updated if you add or remove hosts...this may be an edge-case and/or not applicable to you.

Presumably you have a slightly simplistic case and aren't needing dynamic inventory based on AWS EC2 tags for example?

Let me know what your inventory file, /var/lib/zookeeper/myid, and /etc/zookeeper/zoo.cfg files look like and I'll see if I can offer any further advice.

@eRadical
Copy link

I've had the same issue as @cloudman1978
Inventory contains something like:

---
all:
  children:
    zk_cluster_devel:
      hosts:
        "zk-cluster-[01:03].example.com":
          provider: aws
          ......................

and I managed to fix it via a pre_tasks w/ something like:

- name: Install ZK machines for devel
  become: true
  hosts: zk_cluster_devel
  pre_tasks:
    - name: Set ZK id
      set_fact:
        zookeeper_id: "{{ inventory_hostname | replace('.example.com', '') | replace('zk-cluster-0', '') }}"
  roles:
    - sleighzy.zookeeper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants