Kafka Port Validation Error During Topology Upgrade
search cancel

Kafka Port Validation Error During Topology Upgrade

book

Article ID: 422567

calendar_today

Updated On:

Products

Network Observability CA Performance Management

Issue/Introduction

[ERROR]: Task failed: Conditional result (True) was derived from value of type 'str' at '/opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml:6:9'. Conditionals must have a boolean result.

 

Task failed.

Origin: /opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml:2:3

 

1 # It sets kafka_brokers fact on controller node

2 - name: Validate kafkaPort

    ^ column 3

 

<<< caused by >>>

 

Conditional result (True) was derived from value of type 'str' at '/opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml:6:9'. Conditionals must have a boolean result.

Origin: /opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml:6:9

 

4     that:

5       - kafkaPort is defined

6       - kafkaPort is number or kafkaPort | regex_search('^[0-9]+$')

          ^ column 9

 

Broken conditionals can be temporarily allowed with the `ALLOW_BROKEN_CONDITIONALS` configuration option.

 

fatal: [KafkaBroker1 -> localhost]: FAILED! => {"changed": false, "msg": "Task failed: Conditional result (True) was derived from value of type 'str' at '/opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml:6:9'. Conditionals must have a boolean result."}

Cause

During an upgrade, the Ansible task Validate kafkaPort fails with a type mismatch error. This occurs because the regex_searchfilter returns a string (the match result) instead of a boolean value (True/False), which the Ansible assert module requires.

Affected File: /opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml

The failure is located in the assert logic on line 6: kafkaPort is number or kafkaPort | regex_search('^[0-9]+$')

In newer versions of Ansible, the regex_search filter returns the matching string itself. While a non-empty string is "truthy," Ansible's strict validation requires a literal boolean result for conditional assertions. Because the filter returns a string type, the task fails validation.

Resolution

Workaround

To proceed with the upgrade, you must temporarily bypass the port validation check by commenting out the validation task.

  1. Open the following file: /opt/CA/installer/topology-25.4.2/provisioning/roles/netops_kafka/tasks/set_kafka_bootstrap_servers.yaml

  2. Locate the Validate kafkaPort task (typically lines 2 through 10).

  3. Comment out the entire block as shown below:

YAML
 
# - name: Validate kafkaPort
#   assert:
#     that:
#       - kafkaPort is defined
#       - kafkaPort is number or kafkaPort | regex_search('^[0-9]+$')
#       - kafkaPort | int > 0
#       - kafkaPort | int < 65536
#     fail_msg: "The 'kafkaPort' variable must be a valid port number (1-65535). Current value: {{ kafkaPort }}"
#     success_msg: "kafkaPort validation passed: {{ kafkaPort }}"
  1. Save the file and restart the upgrade process.