I'm hoping someone can help me learn how to work with ansible to achieve
the following. This is my first forray into ansible (1.9.4). I
I am assigning a list variable called 'datadog_checks' to different roles.
Nodes which are in the etcd group would get the following 'datadog_checks'
variable.
datadog_checks:
- etcd
- kubelet
Each datadog check has 2 file copies associated with it. The etcd check
has the following file copies
etcd.py -> /etc/dd-agent-container/checks.d/etcd.py
etcd.yaml -> /etc/dd-agent-container/conf.d/etcd.conf
This same pattern occurs for every check in the datadog_checks list. I
was hoping to dynamically create a hash based on the datadog_checks list
like this.
datadog_checks_hash = []
for x in datadog_checks:
datadog_checks_hash.append({ 'file' : x + '.py', 'path' :
'/etc/dd-agent-container/checks.d'})
datadog_checks_hash.append({ 'file' : x + '.yaml', 'path' :
'/etc/dd-agent-container/conf.d'})
And then iterate over the hash like this
- name: create datadog checks
copy: src="{{ item.file}}" dest="{{ item.path}}{{ item.file}}" mode=0644
with_dict: "{{ datadog_checks_hash }}"
I'm stuck trying to figure out what my options are for creating the
datadog_checks_hash. From what i've read I can't do this in the playbook
itself. Is this suited for doing in a jinja template?
Any pointers or ideas appreciated.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/cf80896f-0bab-4803-85eb-2df02f4a335f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.