Hi,
suppose I have a playbook with variable hosts, like this:
---
- user: ...
hosts: $hosts
tasks:
- ...
(example from the official documentation), so that I can control the hosts via the command line (--extra-vars) or via key-value arguments from an outer
playbook. I like this, because I can use the playbook in both a generic sense (i.e. install my software on a lot of machines), and (via tagged and
conditional tasks) in a specific sense (just for this machine, generate and copy over this configuration, and just for this machine, generate and copy
over this other configuration). I like the fact a single playbook can do this, so it's easier to get my coworkers (who know nothing of Ansible) going.
In this simple use case this works fine.
Now suppose I'd like a default value for the hosts setting, so the playbook can work without explicity specifying the hosts too. My first instinct is to
add the default value into a variable file included later, using vars_files. This doesn't actually work - the variable doesn't get expanded.
My second try is to put a default value directly into the playbook, in vars. This works, but isn't overridden by the argument when I include the playbook
even though it should be according to http://ansible.cc/docs/playbooks2.html#understanding-variable-precedence.
My third try is to name an inventory group with a dollar sign (i.e. $dbs instead of dbs). Amusingly, this works the way I want it but is kinda ugly.
So, are any of these behaviours bugs? Also, if anyone has constructive ideas I'd love to hear them.
On a side note, once we switch to Jinja2 processing in templates, will the default filter be applicable to things like this?