Hi guys,
How are you?
I am new at Ansible and doing some great stuffs until now.
I have those variables:
asm_disks:
-
{ device: ‘sdc’, asm_disk_name: ‘ASM_GRID01’, asm_diskgroup: ‘GRID01’, asm_redundancy: ‘NORMAL’, separator: ‘,’ }
-
{ device: ‘sdd’, asm_disk_name: ‘ASM_GRID02’, asm_diskgroup: ‘GRID01’, asm_redundancy: ‘NORMAL’, separator: ‘,’ }
-
{ device: ‘sde’, asm_disk_name: ‘ASM_GRID03’, asm_diskgroup: ‘GRID01’, asm_redundancy: ‘NORMAL’, separator: ‘’ }
-
{ device: ‘sdf’, asm_disk_name: ‘ASM_DATA01’, asm_diskgroup: ‘DATA’, asm_redundancy: ‘EXTERNAL’, separator: ‘’ }
-
{ device: ‘sdg’, asm_disk_name: ‘ASM_FRA01’, asm_diskgroup: ‘FRA’, asm_redundancy: ‘EXTERNAL’, separator: ‘’ }
-
{ device: ‘sdh’, asm_disk_name: ‘ASM_REDO01_01’, asm_diskgroup: ‘REDO01’, asm_redundancy: ‘EXTERNAL’, separator: ‘,’ }
-
{ device: ‘sdi’, asm_disk_name: ‘ASM_REDO01_02’, asm_diskgroup: ‘REDO01’, asm_redundancy: ‘EXTERNAL’, separator: ‘’ }
-
{ device: ‘sdj’, asm_disk_name: ‘ASM_REDO02_01’, asm_diskgroup: ‘REDO02’, asm_redundancy: ‘EXTERNAL’, separator: ‘,’ }
-
{ device: ‘sdk’, asm_disk_name: ‘ASM_REDO02_02’, asm_diskgroup: ‘REDO02’, asm_redundancy: ‘EXTERNAL’, separator: ‘’ }
I need to do something like this:
A loop to concatenate the asm_disk_name variable using comma (,), I know that I need to use join(‘,’)
The challenge is:
I need to concatenate all of asm_disk_name using comma breaking by asm_diskgroup. So, for example: when loop changes from REDO01 asm_diskgroup to REDO02, I need to register in another variable.
My expected output:
redo01:
‘ASM_REDO01_01’,‘ASM_REDO01_02’
redo02:
‘ASM_REDO01_01’,‘ASM_REDO01_02’
How can I do that?
Thank you!
Marcus