|
| 1 | +- debug: |
| 2 | + msg: | |
| 3 | + terraform_backend_type: {{ terraform_backend_type }} |
| 4 | + terraform_state: {{ terraform_state }} |
| 5 | + cluster_upgrade_system_packages: {{ cluster_upgrade_system_packages | default('undefined') }} |
| 6 | +
|
1 | 7 | # We need to convert the floating IP id to an address for Terraform |
2 | 8 | - name: Look up floating IP |
3 | 9 | include_role: |
|
10 | 16 | set_fact: |
11 | 17 | cluster_floating_ip_address: "{{ os_floating_ip_info.floating_ip_address }}" |
12 | 18 |
|
| 19 | +- name: Install Terraform binary |
| 20 | + include_role: |
| 21 | + name: stackhpc.terraform.install |
| 22 | + |
13 | 23 | - name: Make Terraform project directory |
14 | 24 | file: |
15 | 25 | path: "{{ terraform_project_path }}" |
16 | 26 | state: directory |
17 | 27 |
|
| 28 | +- name: Write backend configuration |
| 29 | + copy: |
| 30 | + content: | |
| 31 | + terraform { |
| 32 | + backend "{{ terraform_backend_type }}" { } |
| 33 | + } |
| 34 | + dest: "{{ terraform_project_path }}/backend.tf" |
| 35 | + |
| 36 | +# Patching in this appliance is implemented as a switch to a new base image |
| 37 | +# So unless explicitly patching, we want to use the same image as last time |
| 38 | +# To do this, we query the previous Terraform state before updating |
| 39 | +- block: |
| 40 | + - name: Get previous Terraform state |
| 41 | + stackhpc.terraform.terraform_output: |
| 42 | + binary_path: "{{ terraform_binary_path }}" |
| 43 | + project_path: "{{ terraform_project_path }}" |
| 44 | + backend_config: "{{ terraform_backend_config }}" |
| 45 | + register: cluster_infra_terraform_output |
| 46 | + |
| 47 | + - name: Extract image from Terraform state |
| 48 | + set_fact: |
| 49 | + cluster_previous_image: "{{ cluster_infra_terraform_output.outputs.cluster_image.value }}" |
| 50 | + when: '"cluster_image" in cluster_infra_terraform_output.outputs' |
| 51 | + when: |
| 52 | + - terraform_state == "present" |
| 53 | + - cluster_upgrade_system_packages is not defined or not cluster_upgrade_system_packages |
| 54 | + |
18 | 55 | - name: Template Terraform files into project directory |
19 | 56 | template: |
20 | 57 | src: "{{ item }}.j2" |
|
24 | 61 | - providers.tf |
25 | 62 | - resources.tf |
26 | 63 |
|
27 | | -- name: Install Terraform binary |
28 | | - include_role: |
29 | | - name: stackhpc.terraform.install |
30 | | - |
31 | 64 | - name: Provision infrastructure |
32 | 65 | include_role: |
33 | 66 | name: stackhpc.terraform.infra |
|
0 commit comments