Hi all,
I have a dictionary with a nested dictionary defined in defaults/main.yml of my role:
file_system_system_vg: name: "A Name" lv: {}
where lv is the nested dictionary.
I can use the nested dictionary in a task like this:
``
`
- name: Create Logicals Volumes on primary VG
lvol: vg={{ file_system_system_vg.name }} lv={{ item.value.name }} size={{ item.value.size }}
with_dict: file_system_system_vg.lv
`
This all works fine when file_system_system_vg
is defined, but i would like to remove it from defaults/main.yml and only run the task when file_system_system_vg.**lv**
is defined elsewhere, so I have tried this:
`
- name: Create Logicals Volumes on primary VG
lvol: vg={{ file_system_system_vg.name }} lv={{ item.value.name }} size={{ item.value.size }}
with_dict: file_system_system_vg.lv | default ({})
`
but it throws an error:
TASK: [file_system | Create Logicals Volumes on primary VG] ******************* fatal: [dsdptgfc06v.devqa.exch.int] => with_dict expects a dict
Please note that file_system_system_vg
is not defined here and neither is``file_system_system_vg.lv.
Does this make sense?
How can I make ansible skip this task when bothfile_system_system_vg
and``file_system_system_vg.lv
are undefined?
N.B when I run the task I need to use the dictionaries within file_system_system_vg.lv
Thanks in advance
Paddy