Re: [ansible-project] getting Asible.errors.AnsibleUndefinedVariable: 'broker' is undefined despite assigning in inventory file

2024-04-22 Thread Todd Lewis
The messages are correct. You have only defined the "broker" variable on 
one set of hosts, and the two hosts indicated in the errors are not in 
that set.


You can fix this in a couple of ways. One way is to define all three 
variables in all three sets of hosts:


qa_eng_kafka_cluster:
   hosts:
 en1qa1-zookpr[01:03].qa:
   broker: false
   schema_registry: false
   zookeeper: true
 en1qa1-kafka[01:06].qa:
   broker: true
   schema_registry: false
   zookeeper: false
 en1qa1-kafka[04:06].qa:
   broker: false
   schema_registry: true
   zookeeper: false

The other way is to define all three variables in a higher group, 
setting them all to false, say, and then at the host level set only the 
ones you want to be true to true:


qa_kafka:
  vars:
broker: false
schema_registry: false
zookeeper: false
  children:
cc:
  children:
qa_eng_kafka_cluster:
   hosts:
 en1qa1-zookpr[01:03].qa:
   zookeeper: true
 en1qa1-kafka[01:06].qa:
   broker: true
 en1qa1-kafka[04:06].qa:
   schema_registry: true

To verify the variables are being set and associated with hosts 
appropriately, you can run:


$ ansible-inventory -i kafka_inventory.yaml --list

Cheers,
—
Todd

On 4/22/24 2:22 PM, Sameer Modak wrote:


Hello Team,

I am putting broker: true and zookeeper: true  in inventory file but i 
still getting below exception as its referred in j2 file


An exception occurred during task execution. To see the full 
traceback, use -vvv. The error was: 
ansible.errors.AnsibleUndefinedVariable: 'broker' is undefined. 
'broker' is undefined


fatal: [en1qa1-zookpr02.qa]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'broker' is undefined. 'broker' is undefined"}


An exception occurred during task execution. To see the full 
traceback, use -vvv. The error was: 
ansible.errors.AnsibleUndefinedVariable: 'broker' is undefined. 
'broker' is undefined


fatal: [en1qa1-zookpr01.qa: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'broker' is undefined. 'broker' is undefined"}



=

jinja 2 file

{% if hostvars[inventory_hostname].zookeeper is defined %}

// jmx exporter scrape config for zookeeper

prometheus.scrape "jmx_exporter_zookeeper" {

  targets = [

    {"__address__" = "{{ v_kafka_host }}:{{ 
v_jmx_exporter_zookeeper_port }}"},


  ]

  scrape_interval = "{{ v_jmx_exporter_scrape_interval }}"

  forward_to = [prometheus.remote_write.mimir.receiver]

}

{% else %}

{% endif %}

{% if hostvars[inventory_hostname].broker is defined %}

// jmx exporter scrape config for Broker

prometheus.scrape "jmx_exporter_broker" {

  targets = [

    {"__address__" = "{{ v_kafka_host }}:{{ v_jmx_exporter_broker_port 
}}"},


  ]

  scrape_interval = "{{ v_jmx_exporter_scrape_interval }}"

  scrape_timeout = "{{ v_jmx_broker_scrape_timeout }}"

  forward_to = [prometheus.remote_write.mimir.receiver]

}

{% else %}

{% endif %}

===

kafka_inventory.yaml Inventory  file

  qa_kafka:

      children:

        cc:

          children:

            qa_eng_kafka_cluster:

               hosts:

                 en1qa1-zookpr[01:03].qa:

                   zookeeper: true

                 en1qa1-kafka[01:06].qa:

                   broker: true

                 en1qa1-kafka[04:06].qa:

                   schema_registry: true

        uc:

          children:

=

running as below


ansible-playbook  -i ansible/inventory/nonprod/kafka_inventory.yaml 
--limit qa_eng_kafka_cluster ansible/grafana-agent-play.yaml -u Kafka 
-b  -k


--
You received this message because you are subscribed to the Google 
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3245ff0a-26b3-4a7c-ae66-fdb1951a4797n%40googlegroups.com 
.


--
Todd

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/87211d46-fde8-4acc-8243-97b0bae47aff%40gmail.com.


[ansible-project] New Release: ansible-core v2.15.11

2024-04-22 Thread ansible-announcements
ANSIBLE-CORE V2.15.11
View this release on:

 * GitHub [https://github.com/ansible/ansible/releases/tag/v2.15.11]
 * PyPI [https://pypi.org/project/ansible-core/v2.15.11/]

CHANGELOG
See the full changelog
[https://github.com/ansible/ansible/blob/v2.15.11/changelogs/CHANGELOG-v2.15.rst]
 
for the changes included in this release.

RELEASE ARTIFACTS
 * Built Distribution: ansible_core-2.15.11-py3-none-any.whl
   
[https://files.pythonhosted.org/packages/72/e8/85c0f15d84f912aa12b77d777cc2893ff527562404d98602af3376ee2b5d/ansible_core-2.15.11-py3-none-any.whl]
 
   - 2250723 bytes * 
  8368f64e6596f009ddf308eab8ac32ae1e2642ec5c0d4c03366e673de14f144c (SHA256)
   
   
 * Source Distribution: ansible_core-2.15.11.tar.gz
   
[https://files.pythonhosted.org/packages/bc/e8/34680ed379dbe6573de3fac8941f3a03de57ad69c6bd2fe3feaa98051c4d/ansible_core-2.15.11.tar.gz]
 
   - 3169655 bytes * 
  b7761454c923f63a3d1fcac97b14e378bcc9a8518c3dde07f3ec0988c4667a9d (SHA256)

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1caf954d-d437-c71d-111d-7840cfa82e55%40redhat.com.


[ansible-project] New Release: ansible-core v2.14.16

2024-04-22 Thread ansible-announcements
ANSIBLE-CORE V2.14.16
View this release on:

 * GitHub [https://github.com/ansible/ansible/releases/tag/v2.14.16]
 * PyPI [https://pypi.org/project/ansible-core/v2.14.16/]

CHANGELOG
See the full changelog
[https://github.com/ansible/ansible/blob/v2.14.16/changelogs/CHANGELOG-v2.14.rst]
 
for the changes included in this release.

RELEASE ARTIFACTS
 * Built Distribution: ansible_core-2.14.16-py3-none-any.whl
   
[https://files.pythonhosted.org/packages/43/bf/c83b1e497a7f850ee8624a87dff32dd32dce6ecbc5950b1e108c739a56db/ansible_core-2.14.16-py3-none-any.whl]
 
   - ‍2218968 bytes * 
  4e939b9a30ba4aa97284290171fa46d4c323c225c1cb6a2e8e751906b46de10c (SHA256)
   
   
 * Source Distribution: ansible_core-2.14.16.tar.gz
   
[https://files.pythonhosted.org/packages/15/b9/a3cd6ffb0787b80a0c7e0bc29a6f2d8719fa5a0c808e3a365c5ed4fad278/ansible_core-2.14.16.tar.gz]
 
   - ‍3148176 bytes * 
  ecfa54de804afa8478c4611565c439fee5d966f1a87710f589c6b075dcef921b (SHA256)

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7c157281-c831-7ebd-e9df-e4ab6fdee1ba%40redhat.com.


[ansible-project] getting Asible.errors.AnsibleUndefinedVariable: 'broker' is undefined despite assigning in inventory file

2024-04-22 Thread Sameer Modak
 

Hello Team,

I am putting broker: true and zookeeper: true  in inventory file but i 
still getting below exception as its referred in j2 file

An exception occurred during task execution. To see the full traceback, use 
-vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'broker' is 
undefined. 'broker' is undefined

fatal: [en1qa1-zookpr02.qa]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'broker' is undefined. 'broker' is undefined"}

An exception occurred during task execution. To see the full traceback, use 
-vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'broker' is 
undefined. 'broker' is undefined

fatal: [en1qa1-zookpr01.qa: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'broker' is undefined. 'broker' is undefined"}


=

jinja 2 file

{% if hostvars[inventory_hostname].zookeeper is defined %}

// jmx exporter scrape config for zookeeper

prometheus.scrape "jmx_exporter_zookeeper" {

  targets = [

{"__address__" = "{{ v_kafka_host }}:{{ v_jmx_exporter_zookeeper_port 
}}"},

  ]

  scrape_interval = "{{ v_jmx_exporter_scrape_interval }}"

  forward_to = [prometheus.remote_write.mimir.receiver]

}

{% else %}

{% endif %}

{% if hostvars[inventory_hostname].broker is defined %}

// jmx exporter scrape config for Broker

prometheus.scrape "jmx_exporter_broker" {

  targets = [

{"__address__" = "{{ v_kafka_host }}:{{ v_jmx_exporter_broker_port }}"},

  ]

  scrape_interval = "{{ v_jmx_exporter_scrape_interval }}"

  scrape_timeout = "{{ v_jmx_broker_scrape_timeout }}"

  forward_to = [prometheus.remote_write.mimir.receiver]

}

{% else %}

{% endif %}

===

kafka_inventory.yaml Inventory  file 

  qa_kafka:

  children:

cc:

  children:

qa_eng_kafka_cluster:

   hosts:

 en1qa1-zookpr[01:03].qa:

   zookeeper: true

 en1qa1-kafka[01:06].qa:

   broker: true

 en1qa1-kafka[04:06].qa:

   schema_registry: true

uc:

  children:

=

running as below 


ansible-playbook  -i ansible/inventory/nonprod/kafka_inventory.yaml --limit 
qa_eng_kafka_cluster ansible/grafana-agent-play.yaml -u Kafka -b  -k

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3245ff0a-26b3-4a7c-ae66-fdb1951a4797n%40googlegroups.com.