Open drzraf opened 6 years ago
Running into this same issue. I can't seem to find any way to pass complex configuration to a role with ansible-container. This seems like a significant oversight and it's put me in a bit of a bind. I'm guessing I'm going to have to find a way to make sure the config file is present in the container and then pass a path to it and have my role read it in separately.
It's wore than that, I just found out that passing a YAML within a string (for piping into from_yaml
in the role) does not work either, as ansible-container magically unwraps it as soon as it's defined either in settings/defaults or within a var_file, and then again when the conductor is running if you've forcibly stringified it:
defaults:
myvar: |
a:
a: 1
b: 2
...
services:
myservice:
roles:
- role: myrole
vars:
a: "{{ a | to_yaml }}"
ISSUE TYPE
container.yml
OS / ENVIRONMENT
SUMMARY
As stated in https://groups.google.com/forum/#!topic/ansible-container/PLFQ10cdNII variable interpolation seems to suffer some strange effect when passed to roles inside
container.yml
. Let's say you want to transmit themysql
property of thesite
object down to a role (which, for example, makes use of{{ mysql.user }}
. Neither:would work (because of interpolation issue) Nor would
because resulting
mysql
object var is not considered an object by the role, but a string. If the former syntax can't be made to work insidecontainer.yml
, at least it should be documented how to correctly pass complex variables.STEPS TO REPRODUCE
Have an object inside
vars/main.yml
Run
ansible-container --debug --vars-files vars/main.yml build
EXPECTED RESULTS
ACTUAL RESULTS