Skip to content

Commit c5de8a7

Browse files
authored
Merge pull request #26 from stackhpc/feat/custom-terraform-template-dir
Add cluster_terraform_template_dir var
2 parents 29a9a6a + 87a087a commit c5de8a7

File tree

2 files changed

+30
-13
lines changed

2 files changed

+30
-13
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

roles/cluster_infra/templates/outputs.tf.j2

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ output "cluster_nodes" {
2424
}
2525
}
2626
],
27+
{% for partition in openhpc_slurm_partitions %}
2728
[
28-
for compute in openstack_compute_instance_v2.compute: {
29+
for compute in openstack_compute_instance_v2.{{ partition.name }}: {
2930
name = compute.name
3031
ip = compute.network[0].fixed_ip_v4
31-
groups = ["{{ cluster_name }}_compute"],
32+
groups = ["{{ cluster_name }}_compute", "{{ cluster_name }}_{{ partition.name }}"],
3233
facts = {
3334
openstack_project_id = data.openstack_identity_auth_scope_v3.scope.project_id
3435
}
3536
}
36-
]
37+
]{{ ',' if not loop.last }}
38+
{% endfor %}
3739
)
3840
}
3941

0 commit comments

Comments
 (0)