Discussion:
[ansible-project] iterating over data
Hank Beatty
2015-06-24 11:28:17 UTC
Permalink
Hello,

Given the data below I would like to create a single task that will
print the url or the filename without having to specify the hardware
(PowerEdge_xxxxx) or the firmware (bios, idrac, etc.).

Any ideas would be very much appreciated.

Thanks,
Hank

Something like:

- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_indexed_items: "{{firmware}}"

OR:

- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_dict: "{{firmware}}"



---
firmware:
PowerEdge_730xd:
bios:
type: bios
url:
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE
filename: BIOS_XR23Y_WN64_1.2.10.EXE
target_version: 1.2.10
search: none
minimum_version: none
idrac:
type: idrac
url:
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
filename:
iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
target_version: 2.10.10.10
search: none
minimum_version: none
raid:
type: raid
url:
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
nic_intel1:
type: nic
url:
http://downloads.dell.com/FOLDER02309982M/1/Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
filename: Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
target_version: 15.5.0
search: X520
minimum_version: none
nic_intel2:
type: nic
url:
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
PowerEdge_720xd:
bios:
type: bios
url:
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
nic:
type: nic
url:
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
PowerEdge_620xd:
bios:
type: bios
url:
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
raid:
type: raid
url:
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
--
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-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/558A9451.3000600%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hagai Kariti
2015-06-27 11:56:33 UTC
Permalink
You can write a small filter plugin that gives you the items of dicts
(something that simply returns an `item.values()` or something like that).
Then you could do:

vars:
# Will create a list of inner dict values inside a list of parent
dict's values
- firmware_items: "{{ firmware.values() | map('get_dict_values') | list
}}"
tasks:
- debug: var=item.url
with_flattened: firmware_items


Alternatively, I wrote a lookup plugin that allows you do chain lookups and
make them iterate on each other. Then you can do this:

tasks:
- debug: item.values.url
with_recursive:
- { name: dict, args: firmware }
- { name: dict, args: "{{item.values}}" }

Lookup plugin is here: https://gist.github.com/hkariti/d07695b4b9c5a68d8c02
Post by Hank Beatty
Hello,
Given the data below I would like to create a single task that will
print the url or the filename without having to specify the hardware
(PowerEdge_xxxxx) or the firmware (bios, idrac, etc.).
Any ideas would be very much appreciated.
Thanks,
Hank
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_indexed_items: "{{firmware}}"
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_dict: "{{firmware}}"
---
type: bios
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE
filename: BIOS_XR23Y_WN64_1.2.10.EXE
target_version: 1.2.10
search: none
minimum_version: none
type: idrac
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
target_version: 2.10.10.10
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02309982M/1/Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
filename: Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
target_version: 15.5.0
search: X520
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
--
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-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1fd734c7-7252-4b0f-b974-8cf6ad69f790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hank Beatty
2015-07-24 12:03:21 UTC
Permalink
Hello Hagai,

This got me going. Thank you.

Is there a way to match a given model (given that I set the 'Model' var
earlier in the playbook)? I need the firmware and that works perfectly
but, I need to limit the firmware that goes to a certain model of server.

Thanks,
Hank

Something like:

- debug: var=Model

- debug: msg={{ item.key }}
when: item.key == 'idrac'
with_recursive:
- { name: dict, args: firmware, "{{ Model }}" }
- { name: dict, args: "{{item.value}}" }

Here is the output of the above:

TASK: [idrac-firmware | debug var=Model]
**************************************
ok: [<some server>] => {
"var": {
"Model": "PowerEdge_R730xd"
}
}

TASK: [idrac-firmware | debug msg={{ item.key }}]
*****************************
skipping: [<some server>] => (item={'key': 'bios', 'value': {'url':
'http://downloads.dell.com/FOLDER02797483M/1/BIOS_CNN4X_WN64_2.5.2.EXE',
'search': 'none', 'target_version': '2.5.2', 'minimum_version': 'none',
'filename': 'BIOS_CNN4X_WN64_2.5.2.EXE'}})
skipping: [<some server>] => (item={'key': 'os_collector', 'value':
{'url':
'http://downloads.dell.com/FOLDER02775623M/1/Diagnostics_Application_5W2KP_WN64_OSC_1.1_X10-00.EXE',
'search': 'none', 'target_version': 1.1000000000000001,
'minimum_version': 'none', 'filename':
'Diagnostics_Application_5W2KP_WN64_OSC_1.1_X10-00.EXE'}})
skipping: [<some server>] => (item={'key': 'bios', 'value': {'url':
'http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE', 'search':
'none', 'target_version': '1.2.10', 'minimum_version': 'none',
'filename': 'BIOS_XR23Y_WN64_1.2.10.EXE'}})
ok: [<some server>] => (item={'key': 'idrac', 'value': {'url':
'http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE',
'search': 'none', 'target_version': '2.10.10.10', 'minimum_version':
'none', 'filename':
'iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE'}})
=> {
"item": {
"key": "idrac",
"value": {
"filename":
"iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE",
"minimum_version": "none",
"search": "none",
"target_version": "2.10.10.10",
"url":
"http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE"
}
},
"msg": "idrac"
}
skipping: [<some server>] => (item={'key': 'bios', 'value': {'url':
'http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE', 'search':
'none', 'target_version': '1.2.10', 'minimum_version': 'none',
'filename': 'BIOS_XR23Y_WN64_1.2.10.EXE'}})
ok: [<some server>] => (item={'key': 'idrac', 'value': {'url':
'http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE',
'search': 'none', 'target_version': '2.10.10.10', 'minimum_version':
'none', 'filename':
'iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE'}})
=> {
"item": {
"key": "idrac",
"value": {
"filename":
"iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE",
"minimum_version": "none",
"search": "none",
"target_version": "2.10.10.10",
"url":
"http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE"
}
},
"msg": "idrac"
}
Post by Hagai Kariti
You can write a small filter plugin that gives you the items of dicts
(something that simply returns an `item.values()` or something like
# Will create a list of inner dict values inside a list of parent
dict's values
- firmware_items: "{{ firmware.values() | map('get_dict_values') |
list }}"
- debug: var=item.url
with_flattened: firmware_items
Alternatively, I wrote a lookup plugin that allows you do chain
- debug: item.values.url
- { name: dict, args: firmware }
- { name: dict, args: "{{item.values}}" }
Lookup plugin is
here: https://gist.github.com/hkariti/d07695b4b9c5a68d8c02
Hello,
Given the data below I would like to create a single task that will
print the url or the filename without having to specify the hardware
(PowerEdge_xxxxx) or the firmware (bios, idrac, etc.).
Any ideas would be very much appreciated.
Thanks,
Hank
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_indexed_items: "{{firmware}}"
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_dict: "{{firmware}}"
---
type: bios
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE
<http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE>
filename: BIOS_XR23Y_WN64_1.2.10.EXE
target_version: 1.2.10
search: none
minimum_version: none
type: idrac
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
<http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE>
iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
target_version: 2.10.10.10
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
<http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE>
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02309982M/1/Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
<http://downloads.dell.com/FOLDER02309982M/1/Network_Firmware_M26VT_WN64_15.5.0_A00.EXE>
filename: Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
target_version: 15.5.0
search: X520
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
<http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE>
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
<http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE>
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
<http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE>
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
<http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE>
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
<http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE>
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1fd734c7-7252-4b0f-b974-8cf6ad69f790%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/1fd734c7-7252-4b0f-b974-8cf6ad69f790%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/55B22989.5030600%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hagai Kariti
2015-07-24 12:44:02 UTC
Permalink
Do you mean add conditions for each iteration? No, you cant do that
currently. Shouldnt be hard, butnI dont have a lot of time to do it myself.
Post by Hank Beatty
Hello Hagai,
This got me going. Thank you.
Is there a way to match a given model (given that I set the 'Model' var
earlier in the playbook)? I need the firmware and that works perfectly but,
I need to limit the firmware that goes to a certain model of server.
Thanks,
Hank
- debug: var=Model
- debug: msg={{ item.key }}
when: item.key == 'idrac'
- { name: dict, args: firmware, "{{ Model }}" }
- { name: dict, args: "{{item.value}}" }
TASK: [idrac-firmware | debug var=Model]
**************************************
ok: [<some server>] => {
"var": {
"Model": "PowerEdge_R730xd"
}
}
TASK: [idrac-firmware | debug msg={{ item.key }}]
*****************************
skipping: [<some server>] => (item={'key': 'bios', 'value': {'url': '
http://downloads.dell.com/FOLDER02797483M/1/BIOS_CNN4X_WN64_2.5.2.EXE',
'search': 'none', 'target_version': '2.5.2', 'minimum_version': 'none',
'filename': 'BIOS_CNN4X_WN64_2.5.2.EXE'}})
{'url': '
http://downloads.dell.com/FOLDER02775623M/1/Diagnostics_Application_5W2KP_WN64_OSC_1.1_X10-00.EXE',
'Diagnostics_Application_5W2KP_WN64_OSC_1.1_X10-00.EXE'}})
skipping: [<some server>] => (item={'key': 'bios', 'value': {'url': '
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE',
'search': 'none', 'target_version': '1.2.10', 'minimum_version': 'none',
'filename': 'BIOS_XR23Y_WN64_1.2.10.EXE'}})
ok: [<some server>] => (item={'key': 'idrac', 'value': {'url': '
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE',
'iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE'}})
=> {
"item": {
"key": "idrac",
"value": {
"iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE",
"minimum_version": "none",
"search": "none",
"target_version": "2.10.10.10",
"http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE"
<http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE>
}
},
"msg": "idrac"
}
skipping: [<some server>] => (item={'key': 'bios', 'value': {'url': '
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE',
'search': 'none', 'target_version': '1.2.10', 'minimum_version': 'none',
'filename': 'BIOS_XR23Y_WN64_1.2.10.EXE'}})
ok: [<some server>] => (item={'key': 'idrac', 'value': {'url': '
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE',
'iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE'}})
=> {
"item": {
"key": "idrac",
"value": {
"iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE",
"minimum_version": "none",
"search": "none",
"target_version": "2.10.10.10",
"http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE"
<http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE>
}
},
"msg": "idrac"
}
You can write a small filter plugin that gives you the items of dicts
(something that simply returns an `item.values()` or something like that).
# Will create a list of inner dict values inside a list of parent
dict's values
- firmware_items: "{{ firmware.values() | map('get_dict_values') | list
}}"
- debug: var=item.url
with_flattened: firmware_items
Alternatively, I wrote a lookup plugin that allows you do chain lookups
- debug: item.values.url
- { name: dict, args: firmware }
- { name: dict, args: "{{item.values}}" }
https://gist.github.com/hkariti/d07695b4b9c5a68d8c02
Post by Hank Beatty
Hello,
Given the data below I would like to create a single task that will
print the url or the filename without having to specify the hardware
(PowerEdge_xxxxx) or the firmware (bios, idrac, etc.).
Any ideas would be very much appreciated.
Thanks,
Hank
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_indexed_items: "{{firmware}}"
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_dict: "{{firmware}}"
---
type: bios
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE
filename: BIOS_XR23Y_WN64_1.2.10.EXE
target_version: 1.2.10
search: none
minimum_version: none
type: idrac
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
target_version: 2.10.10.10
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02309982M/1/Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
filename: Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
target_version: 15.5.0
search: X520
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
filename: SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1fd734c7-7252-4b0f-b974-8cf6ad69f790%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/1fd734c7-7252-4b0f-b974-8cf6ad69f790%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the
Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/ansible-project/GDRoK1yWo9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/55B22989.5030600%40gmail.com
<https://groups.google.com/d/msgid/ansible-project/55B22989.5030600%40gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAO0%3DbmG9oQvLa9fjZ4yVLrkcaALHLrCAMK4vDR61Qn91Udzhrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Hank Beatty
2015-07-24 14:14:18 UTC
Permalink
Yes, adding conditions for each iteration. Exactly.

I can get in there and see if I can modify it.

Are you thinking something like this... :

- debug: msg={{ item.key }}
with_recursive:
- { name: dict, args: firmware, conditional: Model }
# where Model was set at some past point
- { name: dict, args: "{{item.value}}", conditional: 'idrac' }

Or something else.

Thanks,
Hank
Post by Hagai Kariti
Do you mean add conditions for each iteration? No, you cant do that
currently. Shouldnt be hard, butnI dont have a lot of time to do it myself.
Hello Hagai,
This got me going. Thank you.
Is there a way to match a given model (given that I set the
'Model' var earlier in the playbook)? I need the firmware and that
works perfectly but, I need to limit the firmware that goes to a
certain model of server.
Thanks,
Hank
- debug: var=Model
- debug: msg={{ item.key }}
when: item.key == 'idrac'
- { name: dict, args: firmware, "{{ Model }}" }
- { name: dict, args: "{{item.value}}" }
TASK: [idrac-firmware | debug var=Model]
**************************************
ok: [<some server>] => {
"var": {
"Model": "PowerEdge_R730xd"
}
}
TASK: [idrac-firmware | debug msg={{ item.key }}]
*****************************
'http://downloads.dell.com/FOLDER02797483M/1/BIOS_CNN4X_WN64_2.5.2.EXE',
'none', 'filename': 'BIOS_CNN4X_WN64_2.5.2.EXE'}})
skipping: [<some server>] => (item={'key': 'os_collector',
'http://downloads.dell.com/FOLDER02775623M/1/Diagnostics_Application_5W2KP_WN64_OSC_1.1_X10-00.EXE',
'search': 'none', 'target_version': 1.1000000000000001,
'Diagnostics_Application_5W2KP_WN64_OSC_1.1_X10-00.EXE'}})
'http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE',
'none', 'filename': 'BIOS_XR23Y_WN64_1.2.10.EXE'}})
'http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE',
'search': 'none', 'target_version': '2.10.10.10',
'iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE'}})
=> {
"item": {
"key": "idrac",
"value": {
"iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE",
"minimum_version": "none",
"search": "none",
"target_version": "2.10.10.10",
"http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE"
<http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE>
}
},
"msg": "idrac"
}
'http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE',
'none', 'filename': 'BIOS_XR23Y_WN64_1.2.10.EXE'}})
'http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE',
'search': 'none', 'target_version': '2.10.10.10',
'iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE'}})
=> {
"item": {
"key": "idrac",
"value": {
"iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE",
"minimum_version": "none",
"search": "none",
"target_version": "2.10.10.10",
"http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE"
<http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE>
}
},
"msg": "idrac"
}
Post by Hagai Kariti
You can write a small filter plugin that gives you the items of
dicts (something that simply returns an `item.values()` or
# Will create a list of inner dict values inside a list of
parent dict's values
- firmware_items: "{{ firmware.values() |
map('get_dict_values') | list }}"
- debug: var=item.url
with_flattened: firmware_items
Alternatively, I wrote a lookup plugin that allows you do chain
- debug: item.values.url
- { name: dict, args: firmware }
- { name: dict, args: "{{item.values}}" }
https://gist.github.com/hkariti/d07695b4b9c5a68d8c02
Hello,
Given the data below I would like to create a single task that will
print the url or the filename without having to specify the hardware
(PowerEdge_xxxxx) or the firmware (bios, idrac, etc.).
Any ideas would be very much appreciated.
Thanks,
Hank
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_indexed_items: "{{firmware}}"
- name: Print firmfware info
debug: msg="item0 {{ item.0 }} item1 {{ item.1.url }}"
with_dict: "{{firmware}}"
---
type: bios
http://downloads.dell.com/FOLDER02868051M/1/BIOS_XR23Y_WN64_1.2.10.EXE
filename: BIOS_XR23Y_WN64_1.2.10.EXE
target_version: 1.2.10
search: none
minimum_version: none
type: idrac
http://downloads.dell.com/FOLDER02881013M/1/iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
iDRAC-with-Lifecycle-Controller_Firmware_FM1PC_WN64_2.10.10.10_A00.EXE
target_version: 2.10.10.10
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02309982M/1/Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
filename: Network_Firmware_M26VT_WN64_15.5.0_A00.EXE
target_version: 15.5.0
search: X520
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: nic
http://downloads.dell.com/FOLDER02861870M/2/Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
filename: Network_Firmware_6FD9P_WN64_16.5.20_A00.EXE
target_version: 16.5.20
search: X520
minimum_version: 15.5.0
type: bios
http://downloads.dell.com/FOLDER02797465M/1/BIOS_MKCTM_WN64_2.5.2.EXE
filename: BIOS_MKCTM_WN64_2.5.2.EXE
target_version: 2.5.2
search: none
minimum_version: none
type: raid
http://downloads.dell.com/FOLDER02864367M/2/SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
SAS-RAID_Firmware_V43G1_WN64_25.2.2-0004_A03.EXE
target_version: 25.2.2-0004
search: none
minimum_version: none
--
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,
To post to this group, send email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1fd734c7-7252-4b0f-b974-8cf6ad69f790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in
the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/ansible-project/GDRoK1yWo9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email
To post to this group, send email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/55B22989.5030600%40gmail.com
<https://groups.google.com/d/msgid/ansible-project/55B22989.5030600%40gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAO0%3DbmG9oQvLa9fjZ4yVLrkcaALHLrCAMK4vDR61Qn91Udzhrg%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CAO0%3DbmG9oQvLa9fjZ4yVLrkcaALHLrCAMK4vDR61Qn91Udzhrg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
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-project+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/55B2483A.5010001%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...