Is there a way to extract stdout variables from Ansible?

Here is my script:


- hosts: myhost
  sudo: yes
  tasks:
  - name: output bash
    command: rpm -q bash
    register: result

  - debug: msg="{{ result.stderr }}"


Here is the output:

[root@ansi playbooks]$  ansible-playbook which_bash.yml

PLAY [myhost] ***************************************************

TASK [setup] 
*******************************************************************
ok: [myhost]

TASK [which bash RPM] 
**********************************************************
changed: [myhost]
 [WARNING]: Consider using yum module rather than running rpm


TASK [debug] 
*******************************************************************
ok: [myhost] => {
    "bash_version": {
        "changed": true,
        "cmd": [
            "rpm",
            "-q",
            "bash"
        ],
        "delta": "0:00:00.045905",
        "end": "2016-06-11 18:22:07.782431",
        "rc": 0,
        "start": "2016-06-11 18:22:07.736526",
        "stderr": "",
        "stdout": "bash-4.2.46-12.el7.x86_64",
        "stdout_lines": [
            "bash-4.2.46-12.el7.x86_64"
        ],
        "warnings": [
            "Consider using yum module rather than running rpm"
        ]
    }
}

PLAY RECAP 
*********************************************************************
myhost      : ok=3    changed=1    unreachable=0    failed=0

The output works great.  However I'm looking or a way to only extract the 
stdout from that output.  I want nothing but stdout.  How can I do that?

thanks in advance.


-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/054414b5-1fea-4363-a5d2-8f443606b216%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to