ansible-middleware / amq_streams

Apache License 2.0
9 stars 7 forks source link

Wrong number of zookeeper and broker instances counted #52

Closed rmarting closed 1 year ago

rmarting commented 1 year ago
SUMMARY

Executed the playbook using an inventory with 3 zookeepers and 3 brokers, the task of displaying the number of instances shows a wrong number, 2 instead of 3 in both cases:

ISSUE TYPE
ANSIBLE VERSION
ansible 2.10.17
  config file = /home/rmarting/Workspaces/ws-streams/ansible-mw-amq_streams/ansible.cfg
  configured module search path = ['/home/rmarting/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/rmarting/.local/lib/python3.11/site-packages/ansible
  executable location = /home/rmarting/.local/bin/ansible
  python version = 3.11.4 (main, Jun  7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]
COLLECTION VERSION

main branch of the collection

STEPS TO REPRODUCE

It is a full-distributed with authentication playbook similar to:

---
- name: "Ansible Playbook to install a Zookeeper ensemble"
  hosts: all
  remote_user: rhmw
  vars:
    # Installation offline
    amq_streams_common_offline_install: true
    amq_streams_common_download_dir: "/tmp"
    # Enabling Zookeeper Authentication
    amq_streams_zookeeper_auth_enabled: 'true'
    amq_streams_zookeeper_auth_user: zkadmin
    amq_streams_zookeeper_auth_pass: p@ssw0rd
  roles:
    - role: amq_streams_zookeeper
  tasks:
    - name: "Ensure Zookeeper is running and available."
      ansible.builtin.include_role:
        name: amq_streams_zookeeper
  post_tasks:
    - name: "Display numbers of Zookeeper instances managed by Ansible."
      ansible.builtin.debug:
        msg: "Numbers of Zookeeper instances: {{ amq_streams_zookeeper_instance_count }}."
      when:
        - amq_streams_zookeeper_instance_count_enabled is defined and amq_streams_zookeeper_instance_count_enabled

- name: "Ansible Playbook to install a Kafka cluster"
  hosts: all
  remote_user: rhmw
  vars:
    # Installation offline
    amq_streams_common_offline_install: true
    amq_streams_common_download_dir: "/tmp"

    # Enabling Zookeeper Authentication (Must match with the same described above)
    amq_streams_zookeeper_auth_enabled: 'true'
    amq_streams_zookeeper_auth_user: zkadmin
    amq_streams_zookeeper_auth_pass: p@ssw0rd

    # Enabling Kafka BrokerListeners
    amq_streams_broker_listeners:
      - AUTHENTICATED://:{{ amq_streams_broker_listener_port }} # Authenticated
      - REPLICATION://:{{ amq_streams_broker_listener_internal_port }} # Inter broker communication

    # Listener for inter-broker communications
    amq_streams_broker_inter_broker_listener: REPLICATION

    # Enabling Kafka Broker Authentication
    amq_streams_broker_auth_enabled: 'true'
    amq_streams_broker_auth_scram_enabled: 'true'
    amq_streams_broker_auth_listeners:
      - AUTHENTICATED:SASL_PLAINTEXT
      - REPLICATION:SASL_PLAINTEXT

    amq_streams_broker_auth_sasl_mechanisms:
      - PLAIN
      - SCRAM-SHA-512

    # Kafka Plain Users
    amq_streams_broker_auth_plain_users:
      - username: admin
        password: password
      - username: kafkauser
        password: password

    # Setting Kafka user for inter-broker communication
    amq_streams_broker_inter_broker_auth_sasl_mechanisms: PLAIN
    amq_streams_broker_inter_broker_auth_broker_username: interbroker
    amq_streams_broker_inter_broker_auth_broker_password: password

    # Enabling Broker replication
    amq_streams_broker_offsets_topic_replication_factor: 3
    amq_streams_broker_transaction_state_log_replication_factor: 3
    amq_streams_broker_transaction_state_log_min_isr: 2
  roles:
    - role: amq_streams_broker
  tasks:
    - name: "Ensure AMQ Streams Broker is running and available."
      ansible.builtin.include_role:
        name: amq_streams_broker   
  post_tasks:
    - name: "Display numbers of broker instances managed by Ansible."
      ansible.builtin.debug:
        msg: "Numbers of broker instances: {{ amq_streams_broker_instance_count }}."
      when:
        - amq_streams_broker_instance_count_enabled is defined and amq_streams_broker_instance_count_enabled

Using an inventory similar to:

[all]
f38mw01
f38mw02
f38mw03

[zookeepers]
f38mw01
f38mw02
f38mw03

[brokers]
f38mw01
f38mw02
f38mw03
EXPECTED RESULTS

The expected results should be count the exact number of instances of each component: zookeeper, and brokers.

ACTUAL RESULTS

This is the output for the zookeeper instances:

TASK [Display numbers of Zookeeper instances managed by Ansible.] *****************************************************
ok: [f38mw01] => {
    "msg": "Numbers of Zookeeper instances: 2."
}
ok: [f38mw02] => {
    "msg": "Numbers of Zookeeper instances: 2."
}
ok: [f38mw03] => {
    "msg": "Numbers of Zookeeper instances: 2."
}

This is the output for the broker instances:

TASK [Display numbers of broker instances managed by Ansible.] ********************************************************
ok: [f38mw01] => {
    "msg": "Numbers of broker instances: 2."
}
ok: [f38mw02] => {
    "msg": "Numbers of broker instances: 2."
}
ok: [f38mw03] => {
    "msg": "Numbers of broker instances: 2."
}
rpelisse commented 1 year ago

Fixed by #56