There is no facility for a variable file including another. Jinja2 is also not invoked when reading variable files at that time, so include won't help.
On Mon, Jan 5, 2015 at 6:17 AM, Mark <[email protected]> wrote: > Hi, > > I'm trying to create some sort of factory pattern I guess in my vars files > for creating Amazon data pipeline jobs. What I want is to have a list of > dicts, and each one will contain a parameter ("step") that I want to be > different per item. However, since this value is quite large & complicated, > and will be used for 90% of the items, i don't want to have to duplicate > this value 40 or so times. > > So, is it possible to include a vars file in another one? I tried using > jinja2's "include" function, but it complained that certain variables > weren't defined because it was trying to resolve the variables in the > included file. In fact, those variables should be parsed later in the main > play, now when including one vars file into the main one. I can't use roles > because this is part of a larger pattern in which the main vars file is > loaded dynamically depending on another variable. > > Some examples might make clear what I mean. > > Here's my playbook, "create-job.yml": > > - name: "Create a data pipeline and definition for {{ product }} {{ job }}" > hosts: localhost > gather_facts: True > vars_files: > - "vars/pipelines/{{ group }}/env/{{ env }}.yml" > - "vars/pipelines/{{ group }}/{{ job }}.yml" > > > Here's my vars file, "job1.yml", for the "job1" job: > > template: multiple-emr > startTime: 03:00:00 > definitions: > - product: web_v2 > suite: websuite > {% include default_step.yml %} # how to include "default_step.yml"? > - product: db2 > suite: dbsuite > {% include default_step.yml %} > - product: custom > suite: customsuite > {% include custom_step.yml %} > ... x 40 > > > And here's the contents of "default_step.yml": > > s3_precondition: "/raw/data/#{node.myDate}/{{ product }}/" > step: > - "s3://my-bucket/artifacts/emr-jar-2.1.1.jar" > - "com.example.SampleEMR" > - "-Dinput=s3n://example-{{ env }}-data{{ s3_precondition | replace('node.', > '') }}*{{ suite }}_#{myDate}.*.gz" > - "-Doutput=s3n://example-{{ env }}-data/intermediate/data/#{myDate}/{{ > product }}/{{ suite }}/", > - "-DoutputFormat=json", > ... > > > How can I achieve this with ansible? > > Mark > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/cbe7f116-aadf-4d57-94ea-712834cb498a%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/cbe7f116-aadf-4d57-94ea-712834cb498a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzTyMeQcBqXVscJjK64i3urvR0ZWz4XHtqwS%3DH8y0AsiQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
