Skip to content

Commit 3b5bc59

Browse files
committed
Add cluster_terraform_template_dir var
Allow the specification of custom Terraform templates in a directory specified in cluster_terraform_template_dir. If this var is not set, use the default Terraform template supplied in cluster_infra/templates.
1 parent b6eb1cb commit 3b5bc59

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

roles/cluster_infra/tasks/main.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55
cluster_upgrade_system_packages: {{ cluster_upgrade_system_packages | default('undefined') }}
66
77
# We need to convert the floating IP id to an address for Terraform
8-
- name: Look up floating IP
9-
include_role:
10-
name: stackhpc.terraform.infra
11-
tasks_from: lookup_floating_ip
12-
vars:
13-
os_floating_ip_id: "{{ cluster_floating_ip }}"
8+
# if we we have cluster_floating_ip, otherwise assume that we're
9+
# assigning the FIP in Terraform and that it will be available in
10+
# outputs.cluster_gateway_ip.
11+
- block:
12+
- name: Look up floating IP
13+
include_role:
14+
name: stackhpc.terraform.infra
15+
tasks_from: lookup_floating_ip
16+
vars:
17+
os_floating_ip_id: "{{ cluster_floating_ip }}"
1418

15-
- name: Set floating IP address fact
16-
set_fact:
17-
cluster_floating_ip_address: "{{ os_floating_ip_info.floating_ip_address }}"
19+
- name: Set floating IP address fact
20+
set_fact:
21+
cluster_floating_ip_address: "{{ os_floating_ip_info.floating_ip_address }}"
22+
when: cluster_floating_ip is defined
1823

1924
- name: Install Terraform binary
2025
include_role:
@@ -54,7 +59,17 @@
5459

5560
- name: Template Terraform files into project directory
5661
template:
57-
src: "{{ item }}.j2"
62+
src: >-
63+
{{
64+
"{}{}.j2".format(
65+
(
66+
cluster_terraform_template_dir ~ "/"
67+
if cluster_terraform_template_dir is defined
68+
else ""
69+
),
70+
item
71+
)
72+
}}
5873
dest: "{{ terraform_project_path }}/{{ item }}"
5974
loop:
6075
- outputs.tf

0 commit comments

Comments
 (0)