stdout return 2 values

27 views
Skip to first unread message

shlco

unread,
Apr 5, 2022, 1:02:05 PM4/5/22
to Ansible Project
Hi

I try to get PID using Ansible. 
I try run the following lines but instead to get one value (PID) I get 2 values , 1  - PID and 2 - PID of Ansible process that running remotely.

I get: "pid.stdout": "2229\n2456601"
that actually 2229 value I need to store as pid.

---
- name: Gen Tread
   hosts: all
   gather_facts: true
   tasks:
     - name: get PID.
       shell: "ps aux | grep -i jira | grep -i java | awk -F '[  ]*' '{print $2}' "
        register: pid
     - debug:
          var: pid.stdout

Please assist 

Dick Visser

unread,
Apr 6, 2022, 12:58:12 AM4/6/22
to ansible...@googlegroups.com
What are you actually trying to achieve? 
Because from your shell task it seems you intend to do things that could be better done in other ways 

Sent from a mobile device

From: ansible...@googlegroups.com <ansible...@googlegroups.com> on behalf of shlco <shlom...@gmail.com>
Sent: Tuesday, April 5, 2022 6:56:45 PM
To: Ansible Project <ansible...@googlegroups.com>
Subject: [ansible-project] stdout return 2 values
 
--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b929ec49-a549-474d-a676-a2a9d47f04fen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages