I am writing roles for an ansible playbook. In the role I have a defaults folder containing a main.yml to define default values for the variables the role uses. Can I cross-reference within the same object?
For example, I have tried the following:
scripts_config:
host_entry:
dir: "/foo"
file: "{{dir}}/config"
foo: "{{host_entry.dir}}/foo"
bar: "{{scripts_config.host_entry.dir}}/bar"
None of them work. I tried each of file, foo and bar one at a time:
filegave The task includes an option with an undefined variable. The error was: 'dir' is undefinedfoogave The task includes an option with an undefined variable. The error was: 'host_entry' is undefinedbargave An unhandled exception occurred while templating
Is it even possible?
My use case is that I want an object with a directory and several files which would be relative to that in the default set-up. But if you override the defaults you could specify full paths for one or more of the files, so i don't want the task to assume it's relative.