AAP: Code Compatibility
Our good old Red Hat Ansible Tower was recently upgraded to the Ansible Automation Platform. Although the AAP adoption was fast, Ansible compatibility tack derailed half an O&M templates in our organization. The error message says, "Invalid data passed to 'loop', it requires a list, got this instead: dict_keys([])."
The issue comes from the AAP Execution Engine. The Ansible 2.9 container runs on Python 3. That breaks a lot of code that loops through data structures. The meta code below is a generic representation of the original code.
Function d.keys() returns a list for Python 2 and a class for Python3 interpreter. The JDoodle allows you to run the code against different Python engines, as in the screenshot below.
Luckily, the simple explicit typecast fixes the issue.