Browse Source

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
Lukas Kubin 2 years ago
parent
commit
87552b91be
1 changed files with 3 additions and 3 deletions
  1. 3
    3
      workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml

+ 3
- 3
workloads/ansible/shade/lampstack/roles/apply/tasks/main.yml View File

@@ -76,7 +76,7 @@
76 76
     timeout: 200
77 77
     flavor: "{{ app_env.flavor_name }}"
78 78
     network: "{{ app_env.private_net_name }}"
79
-    userdata: "{{ lookup('file', 'templates/userdata.j2') }}"
79
+    userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
80 80
     config_drive: "{{ app_env.config_drive | default('no') }}"
81 81
     security_groups: lampstack_sg
82 82
     floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
@@ -109,7 +109,7 @@
109 109
     timeout: 200
110 110
     flavor: "{{ app_env.flavor_name }}"
111 111
     network: "{{ app_env.private_net_name }}"
112
-    userdata: "{{ lookup('file', 'templates/userdata.j2') }}"
112
+    userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
113 113
     config_drive: "{{ app_env.config_drive | default('no') }}"
114 114
     security_groups: lampstack_sg
115 115
     floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
@@ -154,7 +154,7 @@
154 154
     flavor: "{{ app_env.flavor_name }}"
155 155
     network: "{{ app_env.private_net_name }}"
156 156
     floating_ip_pools: "{{ app_env.public_net_name | default(omit) }}"
157
-    userdata: "{{ lookup('file', 'templates/userdata.j2') }}"
157
+    userdata: "{{ lookup('template', 'templates/userdata.j2') }}"
158 158
     config_drive: "{{ app_env.config_drive | default('no') }}"
159 159
     security_groups: lampstack_sg
160 160
     meta:

Loading…
Cancel
Save