Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That "thing" that you're referring to is handled by Ansible, and not by YAML. It uses the Jinja2 templating engine. And I would assume Ansible uses some sort of scoping order/rules in order to provide values for the template generation.

E.g. look here in the Ansible docs:

http://docs.ansible.com/ansible/latest/playbooks_loops.html#...

It provides a construct that allows you to loop over a sub-list of YAML items, and then let's you use the looped-variable in a string-substitution via the templating language. That's the name: "{{ item }}" that you see there.

Edit. Typo



Thank you! this is what I've been looking for, but searches for token, substitution, and "defining subdirectories" have not led to this. Calling it a loop is confusing.

It seems the values have to be defined in some other file, so I couldn't chain them, though.

Suppose I want to write something like...

  paths:
     BASEDIR: /somedir
     SUBDIR1: {{ paths:BASEDIR }}/subdir1
     SUBDIR2: {{ paths:SUBDIR1 }}/subdir2
Doesn't seem like that would work. I would end up putting all my definitions into a separate file.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: