Change lookup method to correctly load Jinja2 templates.

This should resolve two problems:

* Ansible cannot find `userdata.j2` due to incorrect path used
* Allow the template to be actually rendered as template instead of
  being loaded as plain file without evaluation

There's another solution - simple move of `/roles/apply/templates/`
to `/roles/apply/files/templates/`. I have favored this one though
to make it possible to use Jinja2 expressions in the template file,
which I believe was the original creator's idea.

Change-Id: I268e4967597508e15d7de76051e097a43a0bfeac
This commit is contained in:
Lukas Kubin 2017-01-21 19:30:46 +00:00
parent b642525efe
commit 87552b91be
1 changed files with 3 additions and 3 deletions

View File

@ -76,7 +76,7 @@
timeout: 200
flavor: "{{ app_env.flavor_name }}"
network: "{{ app_env.private_net_name }}"
userdata: "{{ lookup('file', 'templates/userdata.j2') }}"
userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
config_drive: "{{ app_env.config_drive | default('no') }}"
security_groups: lampstack_sg
floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
@ -109,7 +109,7 @@
timeout: 200
flavor: "{{ app_env.flavor_name }}"
network: "{{ app_env.private_net_name }}"
userdata: "{{ lookup('file', 'templates/userdata.j2') }}"
userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
config_drive: "{{ app_env.config_drive | default('no') }}"
security_groups: lampstack_sg
floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
@ -154,7 +154,7 @@
flavor: "{{ app_env.flavor_name }}"
network: "{{ app_env.private_net_name }}"
floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
userdata: "{{ lookup('file', 'templates/userdata.j2') }}"
userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
config_drive: "{{ app_env.config_drive | default('no') }}"
security_groups: lampstack_sg
meta: