The inconsistencies in your indentation lead me to suspect you are withholding evidence. :) Assuming your code is this:

*- name: check previous kafka broker server.properties shell: "ps -ef | grep -i kafka | grep -i server.properties | awk '{print $NF}'" register: serverfile tags: - upgrade - upgrade12 - name: debug grepout set_fact: srvfilepath: "{{ item }}" loop: "{{ serverfile.stdout_lines }}" when: "'server' in item" tags: - upgrade - upgrade12 - name: get the interbroker and messge format version details if set shell: 'grep -e inter.broker.protocol.version -e log.message.format.version {{srvfilepath}}' register: regintbrkpt tags: - upgrade12 - name: display interbroker version debug: msg: "{{ item }}" loop: - "{{regintbrkpt.stdout_lines}}" tags: - upgrade12*

Because the "*display interbroker version*" task is claiming *item* is undefined, then the previous task is not registering anything containing *stdout_lines*. I would not be surprised to find the poorly named "*debug grepout*" task is not finding '*server*' in the expected output from the first task, possibly because the shell pipeline isn't producing what you expect.

Suggestions:
* Run with *-vv* until this is working reliably.
* Insert debug tasks after every task that registers to ensure the data you are passing to subsequent tasks is what you expect. * Consider using *pgrep -f -a kafka* and *grep -o* with to extract relevant data from existing processes command lines.

Good luck; let us know what you find.
--
Todd

On 6/4/23 3:19 PM, Sameer Modak wrote:
Code:

- name: check previous kafka broker server.properties

    shell: "ps -ef | grep -i kafka | grep -i server.properties | awk '{print $NF}'"

    register: serverfile

    tags:

    - upgrade

    - upgrade12


  - name: debug grepout

    set_fact:

      srvfilepath: "{{ item }}"

    loop: "{{ serverfile.stdout_lines }}"

    when: "'server' in  item"

    tags:

    - upgrade

    - upgrade12

- name: get the interbroker and messge format version details if set

    shell: 'grep -e inter.broker.protocol.version -e log.message.format.version {{srvfilepath}}'

    register: regintbrkpt

    tags:

    - upgrade12

- name: display interbroker version

    debug:

      msg: "{{ item }}"

    loop:

    - "{{regintbrkpt.stdout_lines}}"

    tags:

    - upgrade12

  =====================================================


tal: [kafka-kafka-1.acceptance.cloud.8x8.com]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined. 'item' is undefined\n\nThe error appears to be in '/Users/sameer_modak/ansibledemo/kafkainstall.yml': line 353, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: display interbroker version\n^ here\n"}

fatal: [kafka-kafka-2.acceptance.cloud.8x8.com]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined. 'item' is undefined\n\nThe error appears to be in '/Users/sameer_modak/ansibledemo/kafkainstall.yml': line 353, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: display interbroker version\n^ here\n"}

fatal: [kafka-kafka-3.acceptance.cloud.8x8.com]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'item' is undefined. 'item' is undefined\n\nThe error appears to be in '/Users/sameer_modak/ansibledemo/kafkainstall.yml': line 353, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: display interbroker version\n^ here\n"}




--
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/b654c3cb-7b03-448a-87d9-9b44a3676d9en%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/b654c3cb-7b03-448a-87d9-9b44a3676d9en%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
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/76cd21de-a448-1316-f8d2-892d67b264d4%40gmail.com.

Reply via email to