I am trying to simplify some variable files for our developers and I am wondering if I can do this transform with existing filter/lookup plugins Ansible.
I’ll have this dictionary (and the fields are not static, there could be more settings):
OptionSettings:
aws:elasticbeanstalk:command:
BatchSize: ‘30’
BatchSizeType: Percentage
aws:elasticbeanstalk:sns:topics:
Notification Endpoint: me@example.com
And I want to transform the elements under OptionSettings to match what the module/API is expecting:
OptionSettingsTransform:
- Namespace: aws:elasticbeanstalk:command
OptionName: Batch Size
Value: “30” - Namepsace: aws:elasticbeanstalk:command
OptionName: BatchSizeType
Value: Percentage - Namespace: aws:elasticbeanstalk:sns:topics
OptionName: Notification Endpoint
Value: me@example.com
So it involves iterating over each subelement of OptionSettings and then each subelement of each namespace while retaining the namespace it is working within. I have tried looking at with_items, together, subelements, but I can’t seem to wrap my head around it. Any ideas? Is this too much and would I need to implement a custom lookup plugin in python to do this?
Any help/suggestions would be appreciated