Can anyone tell me what is hostvars[host]|confluent.platform.resolve_hostname in variable

zookeeper_servers: “{% for host in groups[‘zookeeper’] %}{% if loop.index > 1%},{% endif %}server.{{ hostvars[host][‘zookeeper_id’] | default(groups.zookeeper.index(host) + 1)}}={{ zookeeper_current_node_hostname if host == inventory_hostname else hostvars[host]|confluent.platform.resolve_hostname }}:{{zookeeper_peer_port}}:{{zookeeper_leader_port}}{% endfor %}”

Goes through selected possible VARs to provide the HOSTNAME for a given node for internal addressing within Confluent Platform

Taken from

1 Like

Thanks Mike. However, i dont want to use it as confluent.platform.resolve_hostname. We are customising as per our requirement so how do we restrain from using confluent.platform.resolve_hostname cant we directly use “|resolve_hostname” or similar to it . I wanted to avoid using collection and use it as a role.

I wanted to avoid using collection and use it as a role.

Im not sure what you mean by this. Could you elaborate?

If you just dont want to use this specific collection, you could either maintain a copy of the plugin yourself, or write the logic in jinja/ansible. Maybe like

..... if host == inventory_hostname else (
  hostvars[host]['hostname_aliasing_enabled'] | ternary(
    (
      hostvars[host]['hostname'] | default(
        hostvars[host]['ansible_host' ] | default(
          hostvars[host]['inventory_hostname']
        )
      )
    ),
    (
      hostvars[host]['inventory_hostname']
    )
  )
)

Yes i want to maintain the local copy of plugin.
Now what happens is because the variable is used like "confluent.platform.resolve_hostname " its obliged to have ansible colletion FCQN like ansible/collections/ansible_collections/confluent/platform/ . I dont want this to have it on control machine. Is it not possible to use simply hostvars[host]|resolve_hostname instead hostvars[host]|confluent.platform.resolve_hostname. If i can use like this i dont need to have ansible collection directory structure to maintain. I can simply use it as a role.

Yes i want to maintain the local copy of plugin.

You can place the copy of the plugin locally as described here: Filter plugins — Ansible Community Documentation

Or you can adjust your variable like this. Im not confident this works, but I think you can take it from here

zookeeper_servers: “{% for host in groups[‘zookeeper’] %}{% if loop.index > 1%},{% endif %}server.{{ hostvars[host][‘zookeeper_id’] | default(groups.zookeeper.index(host) + 1)}}={{ zookeeper_current_node_hostname if host == inventory_hostname else (hostvars[host]['hostname_aliasing_enabled'] | ternary((hostvars[host]'hostname'] | default(hostvars[host]['ansible_host' ] | default(hostvars[host]['inventory_hostname']))), (hostvars[host]['inventory_hostname']))) }}:{{zookeeper_peer_port}}:{{zookeeper_leader_port}}{% endfor %}”

Sure. Thanks for your reply mike. I will try and let u know

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.