Help with ansible local_action with_items and debug

248 views
Skip to first unread message

Rogério Ceni Coelho

unread,
Mar 4, 2019, 10:07:59 AM3/4/19
to Ansible Project
Hi Ansible Jedi´s !!!

I need some help with this example running a local_action.

This playbook returns only debug information for the last item on local_action. 

What are the right way to print debug for all items ???

[root@prd-rbs-ansible26-poa ansible]# cat  playbooks/prd-rbs-ovirt42-storage-facts.yml
- hosts: localhost
  tasks:

    - name: Retrieve facts about one or more oVirt/RHV storage domains - (ovirt_storage_domain_facts)
      local_action:
         module: ovirt_storage_domains_facts
         auth:
            username: admin@internal
            password: thisisthepassword
         pattern: name="{{ item.storage_domain_name }}" and datacenter="{{ item.storage_domain_datacenter_name }}"
      with_items:
        - { storage_domain_name: 'VNX55001_PRD42_DATA', storage_domain_datacenter_name: 'Default' }
        - { storage_domain_name: 'UNITY_PRD42_DATA_DOMAIN', storage_domain_datacenter_name: 'Default' }
        - { storage_domain_name: 'NASUNITY_PRD_OVIRT42_DATA_DOMAIN', storage_domain_datacenter_name: 'Default' }
        - { storage_domain_name: 'ISO_DOMAIN', storage_domain_datacenter_name: 'Default' }
    - debug:
        var: ovirt_storage_domains
[root@prd-rbs-ansible26-poa ansible]# 

[root@prd-rbs-ansible26-poa ansible]# ansp playbooks/prd-rbs-ovirt42-storage-facts.yml 

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

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

TASK [Retrieve facts about one or more oVirt/RHV storage domains - (ovirt_storage_domain_facts)] ********************************************************************************
ok: [localhost -> localhost] => (item={u'storage_domain_name': u'VNX55001_PRD42_DATA', u'storage_domain_datacenter_name': u'Default'})
ok: [localhost -> localhost] => (item={u'storage_domain_name': u'UNITY_PRD42_DATA_DOMAIN', u'storage_domain_datacenter_name': u'Default'})
ok: [localhost -> localhost] => (item={u'storage_domain_name': u'NASUNITY_PRD_OVIRT42_DATA_DOMAIN', u'storage_domain_datacenter_name': u'Default'})
ok: [localhost -> localhost] => (item={u'storage_domain_name': u'ISO_DOMAIN', u'storage_domain_datacenter_name': u'Default'})

TASK [debug] ********************************************************************************************************************************************************************
ok: [localhost] => {
    "ovirt_storage_domains": [
        {
            "available": 484257562624, 
            "backup": false, 
            "comment": "ISO_DOMAIN", 
            "committed": 0, 
            "critical_space_action_blocker": 5, 
            "data_centers": [
                {
                    "href": "/ovirt-engine/api/datacenters/cca34032-c685-11e8-b6e5-001dd8b72533", 
                    "id": "cca34032-c685-11e8-b6e5-001dd8b72533"
                }
            ], 
            "description": "ISO_DOMAIN", 
            "discard_after_delete": false, 
            "disk_profiles": [], 
            "disk_snapshots": [], 
            "external_status": "ok", 
            "files": [], 
            "href": "/ovirt-engine/api/storagedomains/b684cd6c-3090-4ce5-9bdc-5fb099beab77", 
            "id": "b684cd6c-3090-4ce5-9bdc-5fb099beab77", 
            "master": false, 
            "name": "ISO_DOMAIN", 
            "permissions": [], 
            "storage": {
                "address": "spitzer.srv.srvr.rbs.net", 
                "nfs_version": "auto", 
                "path": "/u00/oVirt/PRD42/ISO_DOMAIN", 
                "type": "nfs"
            }, 
            "storage_connections": [], 
            "storage_format": "v1", 
            "supports_discard": false, 
            "supports_discard_zeroes_data": false, 
            "type": "iso", 
            "used": 86973087744, 
            "warning_low_space_indicator": 10, 
            "wipe_after_delete": false
        }
    ]
}

PLAY RECAP **********************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=0   

[root@prd-rbs-ansible26-poa ansible]# 
Reply all
Reply to author
Forward
0 new messages