From 9e30af09e2a6cb38f9a1ec1ccc5ab90e5eb6eab5 Mon Sep 17 00:00:00 2001 From: Graham Trummell Date: Sat, 18 Mar 2017 03:46:23 -0700 Subject: [PATCH] Pipe datadog_checks through list for Python 3 I ran into [an issue described in Ansible on Python 3](https://github.com/ansible/ansible/issues/19514), in which the module fails when trying to iterate through keys: ``` TASK [Datadog.datadog : Create a configuration file for each Datadog check] **** failed: [default] (item=dict_keys(['process'])) => {"failed": true, "item": "dict_keys(['process'])", "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute \"dict_keys(['process'])\""} PLAY RECAP ********************************************************************* default : ok=8 changed=6 unreachable=0 failed=1 ``` Ansible developers recommend piping dicts through `list` to work around this issue. Trying this on my own Ansible 2.2.1.0/Python 3 environment, I was able to eliminate the issue. The discussion on the issue indicates that this is backward-compatible with lesser versions of Ansible and Python. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 2aa3629f..87ffaf51 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -33,6 +33,6 @@ dest: /etc/dd-agent/conf.d/{{ item }}.yaml owner: '{{ datadog_user }}' group: '{{ datadog_group }}' - with_items: '{{ datadog_checks.keys() }}' + with_items: '{{ datadog_checks|list }}' notify: - restart datadog-agent