I have a list of objects with names like this: ‘obj-0001’, ‘obj-0002’ and need to set_stats with some data about these objects in the following structure:
“data”: {
“obj-0001”: { “a”: 1, “b”: 2 },
“obj-0002”: { “a”: 3, “b”: 4 }
}
They then can be referenced as data[‘obj-0001’].a
set_stats:
data:
‘obj_0001’: 5 # this works
‘obj-0002’: 6 # this does NOT work: the variable name ‘obj-0002’ is not valid
As far as I understand, there is no limitation on character set in keys while they are accessed using quotes in brackets: data[‘obj-0002’].
Is there any way to make such assignment in ansible? I really do not want to restrict character sets in hash keys to alphanumeric only if possible.