The above example does not work, at least using vars or includes that define “image_name”.
What I am trying to do is pass VM parameters to OpenStack, and one of those is the image ID which is a very long non-sensical string. I would like to define those with human-readable names. Curiously the Nova compute module in Ansible doesn’t like the name, only the ID, where as command line nova will accept the name as well. Perhaps this is a limitation in YAML.
What you have is in fact fine, we’d have to see your playbook in context to say what’s up.
If hostname is meant to be something that Ansible recognizes, or groups, that’s not something ansible knows what to do with, which may be why you percieve something to not work.
Also please share any output you may have that makes you think the variable isn’t being used, as well as the version of Ansible you are using.
Here is the main playbook with a simple experiment to set the variable “centos-6.4” to the image id. I would prefer to do it with a role variable file or include, but this eliminates any other issues and just highlights the variable substitution: