Re: [ansible-project] item variable not defined loop does not work well with stdout_lines

2023-06-04 Thread Todd Lewis
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 
.


--
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.


[ansible-project] item undefined when try to use through loop 2nd time

2023-06-04 Thread Sameer Modak
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: [host1]: 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: [host2]]: 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: [host3]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/bb0dbae7-46c1-46f2-bced-e3a7cc914b2dn%40googlegroups.com.


[ansible-project] item variable not defined loop does not work well with stdout_lines

2023-06-04 Thread Sameer Modak
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.


Re: [ansible-project] JOB | Linux Sysadmin (London, UK)

2023-06-04 Thread Nico Kadel-Garcia
On Fri, Jun 2, 2023 at 10:20 AM James Tobin  wrote:
>
> Hello, I'm working with an employer that is looking to hire a Linux
> sysadmin with terraform, ansible and python experience for an
> infrastructure position in London.  I had hoped some members of this

This is a technical mailing list. Please, let's not start doing job
postings here.

-- 
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/CAOCN9ry8U7grKMzBdeKb%2BdsGriKF5xmY6uMg2tx7bsVisFxXxw%40mail.gmail.com.


Re: [ansible-project] check connectivity (telnet

2023-06-04 Thread Vladimir Botka
On Sun, 4 Jun 2023 12:06:39 +0200 (CEST)
dulhaver via Ansible Project  wrote:

> ... couple of postgres-remotes ...
> ... to check whether postgres1 has a connection via port 5432 to a specific 
> IP address ...
> ... what would be the right approach (aka module) for such in an Ansible TASK?

Use the module *wait_for*. See
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/wait_for_module.html


If you run the play on *postgres1* the task is simple

  - hosts: postgres1
tasks:
  - wait_for:
  host: 
  port: 5432

If you run the play on multiple hosts you might want to run
once and delegate the task 

  - hosts: all
tasks:
  - wait_for:
  host: 
  port: 5432
delegate_to: postgres1
run_once: true

See: pg_isready
https://www.postgresql.org/docs/current/app-pg-isready.html

-- 
Vladimir Botka

-- 
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/20230604133822.77edfdfe%40gmail.com.


pgpb_WiJgBzw3.pgp
Description: OpenPGP digital signature


Re: [ansible-project] check connectivity (telnet

2023-06-04 Thread Dick Visser
Do you want to check if the server has an established connection to an IP
address?
Or if it is listening on a specific port?
There are perhaps better ways of finding out if a server is running at some
socket

On Sun, 4 Jun 2023 at 12:06, dulhaver via Ansible Project <
ansible-project@googlegroups.com> wrote:

> hi,
>
> I am running a playbook og a couple of postgres-remotes who play different
> roles in a complex server landscape.
>
> Now I want to check to check whether i.e. postgres1 has a connection via
> port 5432 to a specific IP address. The true/false like result of such a
> check should be saved into a variable.
>
> Manually I could i.e. do this with something like 'telnet 
> 5432'
>
> what would be the right approach (aka module) for such in an Ansible TASK?
>
> --
> 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/1926803861.486837.1685873199295%40office.mailbox.org
> 
> .
>
-- 
Sent from Gmail Mobile

-- 
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/CAF8BbLbK_y%3DavxUo3WrVrqQtfz_-%3DFV5aGgZgFbHhjz1psaAAA%40mail.gmail.com.


[ansible-project] check connectivity (telnet

2023-06-04 Thread dulhaver via Ansible Project
hi,
 
I am running a playbook og a couple of postgres-remotes who play different 
roles in a complex server landscape.
 
Now I want to check to check whether i.e. postgres1 has a connection via port 
5432 to a specific IP address. The true/false like result of such a check 
should be saved into a variable.
 
Manually I could i.e. do this with something like 'telnet  5432'
 
what would be the right approach (aka module) for such in an Ansible TASK?

-- 
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/1926803861.486837.1685873199295%40office.mailbox.org.