use quotes inside the shell "rpm -q {{ item }}" also you can list for for
rpms using the yum module.

On Fri, Mar 22, 2019 at 3:51 PM Jerry Seven <[email protected]> wrote:

> I cant figure out why
>
> ---
> - hosts: misc
>   become: false
>   gather_facts: yes
>   tasks:
>     - name: get package version
>       shell: rpm -q {{ item }}
>       with_items:
>         - "package1"
>         - "package2"
>         - "package3"
>       register: pkg
>
>     - debug:
>         msg: "{{ pkg.stdout }}"
>
>
> FAILED! => {"msg": "The task includes an option with an undefined
> variable. The error was: 'dict object' has no attribute 'stdout'\n\nThe
> error appears to have been in '/opt/ansible/foo.yml': line 14, column 7,
> but may\nbe elsewhere in the file depending on the exact syntax
> problem.\n\nThe offending line appears to be:\n\n\n    - debug:\n      ^
> here\n\nexception type: <class
> 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no
> attribute 'stdout'"}
>
> --
> 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/6670d74d-dcb1-4120-8e26-e14718d329bb%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6670d74d-dcb1-4120-8e26-e14718d329bb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 

Jonathan lozada de la matta

AUTOMATION PRACTICE

-- 
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/CAFYJA%2BKR06C3FOjZe6qGPgpHRf57JG%2Be%3D-Kc4NY6c%3Do2hkxMWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to