ansible/ansible — pull request #1121 by jpmens (2012-09-28 09:43:30+00:00)
Title: Feature: lookup external data for variable expansion

This implements a proof of concept for two new lookup types (**lots** planned) which can be used to look up data externally from Playbooks.

```yaml

---
- hosts: 127.0.0.1
gather_facts: false
connection: local
vars:
- resp: $STAB(redis;a1)
- resp: $STAB(env;HOME)
tasks:
- action: command /bin/echo ${resp}
- action: template src=stab1.in dest=/tmp/s1
```

I repeat, that it's a PoC, but I'd very much like to expand on this.

Ideas for lookup types:

* Redis: `get` the value of a key.
* Environment: obtain a copy of, say, `$HOME`
* LDAP: search for `attribute=value` and return the value of a named attribute type
* memcached: pass in a key (hash) and return the string
* zeromq: same
* CSV: from a configured CSV file (specified in, say, `ansible.cfg`) retrieve an option from a particular section.
* etc., etc., etc.

Need I say more? ;-)

BTW, the name _stab_ is from a beautiful function in the venerable _sendmail_ daemon; during a debugging session years and years ago, I stumbled over that and thought it a good name. :-)