Skip to content

Commit a6d8108

Browse files
committed
Re-use cluster_infra role for image-build infra
1 parent 7c4fcce commit a6d8108

File tree

4 files changed

+13
-44
lines changed

4 files changed

+13
-44
lines changed

roles/cluster_infra/tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373
else 'vd'
7474
}}
7575
# Only run when block_device_prefix isn't set as an extravar
76-
when: block_device_prefix is not defined
76+
when:
77+
- block_device_prefix is not defined
78+
- cluster_image is defined
7779

7880

7981
- name: Template Terraform files into project directory

roles/image_build/defaults/main.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
---
2-
image_build_terraform_project_path: "{{ playbook_dir }}/terraform-image-build"
3-
image_build_cluster_id: "image-build"
4-
5-
# Regex to capture existing cloud image names to use as the
6-
# OpenHPC Slurm base-image
7-
image_build_existing_image_regex: "^Rocky-8-GenericCloud-Base-8.7-.*"
8-
# Attributes to sort the list of existing base images returned by
9-
# image_build_existing_image_regex. See
10-
# https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/data-sources/images_image_ids_v2#sort
11-
image_build_existing_image_sort_attributes: "name,updated_at"
12-
132
# Attach a floating IP to the Packer build instance
143
image_build_attach_floating_ip: false
154

roles/image_build_infra/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
23
image_build_terraform_project_path: "{{ playbook_dir }}/terraform-image-build"
34
image_build_cluster_id: "image-build"
45

roles/image_build_infra/tasks/main.yml

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,16 @@
11
---
2-
- debug:
3-
msg: |
4-
terraform_backend_type: {{ terraform_backend_type }}
5-
terraform_state: {{ terraform_state }}
6-
7-
- name: Install Terraform binary
8-
include_role:
9-
name: stackhpc.terraform.install
10-
11-
- name: Make Terraform project directory
12-
file:
13-
path: "{{ image_build_terraform_project_path }}"
14-
state: directory
15-
16-
- name: Write backend configuration
17-
copy:
18-
content: |
19-
terraform {
20-
backend "{{ terraform_backend_type }}" { }
21-
}
22-
dest: "{{ image_build_terraform_project_path }}/backend.tf"
23-
24-
- name: Template Terraform files into project directory
25-
template:
26-
src: "{{ item }}.j2"
27-
dest: "{{ image_build_terraform_project_path }}/{{ item }}"
28-
loop:
29-
- outputs.tf
30-
- providers.tf
31-
- resources.tf
2+
- name: Get path to the image-buid Terraform templates directory
3+
set_fact:
4+
image_build_terraform_template_dir: "{{ role_path }}/templates"
325

33-
- name: Provision infrastructure
6+
- name: Run cluster_infra role with image-build terraform template
347
include_role:
35-
name: stackhpc.terraform.infra
8+
name: cluster_infra
9+
public: true
3610
vars:
11+
cluster_id: "{{ image_build_cluster_id }}"
12+
cluster_name: "{{ image_build_cluster_id }}"
13+
cluster_terraform_template_dir: "{{ image_build_terraform_template_dir }}"
3714
terraform_project_path: "{{ image_build_terraform_project_path }}"
3815

3916
- name: Set image build infrastructure facts

0 commit comments

Comments
 (0)