ansible-datadog
ansible-datadog copied to clipboard
The generated integration configs don't honor the order set in the playbook
Datadog rabbitmq node configuration will generate a wrong config.yaml file when we use node in datadog_checks variable.
Example:
datadog_checks:
rabbitmq:
init_config:
service: rabbitmq_redis
instances:
- rabbitmq_api_url: http://localhost:15672/api/
rabbitmq_user: My_user
rabbitmq_pass: mypassword
vhosts:
- my_vhost
nodes:
- redis_cluster_node
Will generate this wrong config.yaml file:
init_config:
service: rabbitmq_redis
instances:
- nodes:
- redis_cluster_node
rabbitmq_api_url: http://localhost:15672/api/
rabbitmq_pass: mypassword
rabbitmq_user: My_user
vhosts:
- my_vhost
When we expect this config.yaml file:
init_config:
service: rabbitmq_redis
instances:
- rabbitmq_api_url: http://localhost:15672/api/
rabbitmq_pass: mypassword
rabbitmq_user: My_user
vhosts:
- my_vhost
nodes:
- redis_cluster_node
When using the "nodes" key, Ansible treats it as a re-organization of the elements in the data structure. Instead of simply renaming the key, Ansible considers it a new key with an associated value, and it re-arranges the other keys around this new key in the YAML output.
PS: check about map('combine') in ansible.
Hi :wave: thanks for opening this issue report.
I have to say I'm not exactly sure where the problem is. Yes, Ansible indeed reorganizes the keys, but the resulting yaml still represents the same structure. You can try parsing the resulting yaml and the yaml you expected by any yaml parser and you'll get the same results (at least I did, I might have missed something). Can you explain exactly what problem you're seeing with the config that you get?
This looks related to https://github.com/DataDog/ansible-datadog/pull/557. It's still unclear how the reordering "breaks" anything but it looks like it does confuse some people; I'll create a backlog card to look at this.
EDIT: I'll also rename this issue to better represent the issue at hand.