I am using Ansible Datadog role and trying to install and configure datadog agents in target servers however, i am stuck at a point where i need to use host variables and update a section of the playbook using these variables. The host variable may have multiple values separated by a space. I want to ensure that these values are added in the playbook based on the variable values. Following example will help in understanding the requirement.
Playbook:
- hosts: servers
roles:
- { role: datadog.datadog, become: yes }
vars:
datadog_api_key: “{{ DD_API_KEY }}”
datadog_config: tags: - “AID:”{{ AID }}"
Here, the tag value AID is using a host variable with the same name i.e., AID and in some cases this host variable can have values like the following:
AID: 100 101 102 103
Is there a way that the while executing tag section of the playbook is parsed based on the variable values in following format or atlease the end result in the target file has this same structure?
tags:
- AID: 100
- AID: 101
- AID: 102
- AID: 103
I believe i cannot use templates for such requirements since the configurations are used under vars in the role. Any suggests would be appreciated.