ansible/ansible — pull request #9563 by EvanK (2014-11-15 22:02:19+00:00)
Title: Adding nested dictionary lookups

This lookup accepts nested dicts of potentially any depth, and recursively flattens them to a single dict with a `value` and one or more numbered keys (`key_0`, `key_1`, `key_N`).

My use case for this was dicts nested two levels deep for configuring an ini file (where the first level was a section name and the second level was the option name and the scalar value for it):
```yml
# roles/php/vars/main.yml
---
php_ini:
PHP:
short_open_tag: "Off"
expose_php: "Off"
error_reporting: "E_ALL & ~E_DEPRECATED & ~E_STRICT"
display_errors: "Off"
display_startup_errors: "Off"
track_errors: "On"
log_errors: "On"
error_log: "/var/log/php_error.log"
Date:
"date.timezone": "America/Chicago"
"mail function":
sendmail_path: "sendmail -t -i"
opcache:
"opcache.enable": 1
"opcache.enable_cli": 0
"opcache.fast_shutdown": 0
```

And the example task:
```yml
# roles/php/tasks/main.yml
---
- name: Configure php.ini
ini_file: >
dest=/etc/php5/cli/php.ini
section="{{ item.key_0 }}"
option="{{ item.key_1 }}"
value="{{ item.value }}"
with_nested_dict: php_ini
```