Hi Team,

I am able to extract the selected list of installed rpms using ansible 
"shell" module ,But when I tried using "yum" module ,it's no success . 
Your help would be appreciated . 

The playbook which is running with "shell" module & it's output is as 
follows ---


Playbook---

---
- hosts: localhost
  tasks:
    - name: Create a list
      set_fact:
        package_list:
          - zlib
          - parted
          - gawk

    - name: Display Lists
      debug:
        msg:
         - "{{ package_list }}"


    - name: ensure a list of packages installed
      shell: rpm -qa "{{ item }}"
      with_items: "{{ package_list }}"
      register: ensure_list
      args:
        warn: false


 
    - name: show results values from ensure_list & filtering one of the key 
attribute called 'stdout'
      debug:
        msg: "{{ ensure_list.results | map(attribute='stdout')|list }}"





================================================Output 
=======================


PLAY [localhost] 
********************************************************************************************************************************************

TASK [Gathering Facts] 
**************************************************************************************************************************************
ok: [localhost]

TASK [Create a list] 
****************************************************************************************************************************************
ok: [localhost]

TASK [Display Lists] 
****************************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        [
            "zlib",
            "parted",
            "gawk"
        ]
    ]
}

TASK [ensure a list of packages installed] 
******************************************************************************************************************
changed: [localhost] => (item=zlib)
changed: [localhost] => (item=parted)
changed: [localhost] => (item=gawk)


TASK [show results values from ensure_list] 
*****************************************************************************************************************
ok: [localhost] => {
    "msg": [
        "zlib-1.2.7-18.el7.x86_64",
        "parted-3.1-31.el7.x86_64",
        "gawk-4.0.2-4.el7_3.1.x86_64"
    ]
}

PLAY RECAP 
**************************************************************************************************************************************************
localhost                  : ok=6    changed=1    unreachable=0    
failed=0    skipped=0    rescued=0    ignored=0

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5c0e4a0f-e4cb-4736-ab83-3c893052647d%40googlegroups.com.

Reply via email to