Skip to content

Install playbook now fails if Terraform is not already installed #25

@AlexCK-STFC

Description

@AlexCK-STFC

I'm not sure why this is an issue now, perhaps an upstream update. But the install playbook now produces a string, not a list, for terraform_available_versions if no versions are present, causing the Filter terraform versions task to fail:

Using /home/ubuntu/azimuth/cloud-azimuth-config/environments/stfc-dev/ansible.cfg as config file
running playbook inside collection azimuth_cloud.azimuth_ops

PLAY [Provision seed node using OpenTofu] **************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [Install Terraform] *******************************************************
included: azimuth_cloud.terraform.install for localhost

TASK [azimuth_cloud.terraform.install : Check if Terraform binary exists in search directories] ***
ok: [localhost] => (item=/home/ubuntu/azimuth/cloud-azimuth-config/.bin) => {"ansible_loop_var": "item", "changed": false, "item": "/home/ubuntu/azimuth/cloud-azimuth-config/.bin", "stat": {"exists": false}}
ok: [localhost] => (item=/home/ubuntu/azimuth/cloud-azimuth-config/.venv/bin) => {"ansible_loop_var": "item", "changed": false, "item": "/home/ubuntu/azimuth/cloud-azimuth-config/.venv/bin", "stat": {"exists": false}}
ok: [localhost] => (item=/usr/local/sbin) => {"ansible_loop_var": "item", "changed": false, "item": "/usr/local/sbin", "stat": {"exists": false}}
ok: [localhost] => (item=/usr/local/bin) => {"ansible_loop_var": "item", "changed": false, "item": "/usr/local/bin", "stat": {"exists": false}}
ok: [localhost] => (item=/usr/sbin) => {"ansible_loop_var": "item", "changed": false, "item": "/usr/sbin", "stat": {"exists": false}}
ok: [localhost] => (item=/usr/bin) => {"ansible_loop_var": "item", "changed": false, "item": "/usr/bin", "stat": {"exists": false}}
ok: [localhost] => (item=/sbin) => {"ansible_loop_var": "item", "changed": false, "item": "/sbin", "stat": {"exists": false}}
ok: [localhost] => (item=/bin) => {"ansible_loop_var": "item", "changed": false, "item": "/bin", "stat": {"exists": false}}
ok: [localhost] => (item=/usr/games) => {"ansible_loop_var": "item", "changed": false, "item": "/usr/games", "stat": {"exists": false}}
ok: [localhost] => (item=/usr/local/games) => {"ansible_loop_var": "item", "changed": false, "item": "/usr/local/games", "stat": {"exists": false}}
ok: [localhost] => (item=/snap/bin) => {"ansible_loop_var": "item", "changed": false, "item": "/snap/bin", "stat": {"exists": false}}

TASK [azimuth_cloud.terraform.install : Get available Terraform versions] ******
skipping: [localhost] => {"changed": false, "skipped_reason": "No items in the list"}

TASK [azimuth_cloud.terraform.install : Set Terraform versions fact] ***********
ok: [localhost] => {"ansible_facts": {"terraform_available_versions": "[\n  ]"}, "changed": false}

TASK [azimuth_cloud.terraform.install : Filter Terraform versions] *************
[ERROR]: Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'terraform_acceptable_versions': object of type 'str' has no attribute 1

Task failed.
Origin: /home/ubuntu/azimuth/cloud-azimuth-config/.ansible/collections/ansible_collections/azimuth_cloud/terraform/roles/install/tasks/main.yml:26:3

24       ]
25
26 - name: Filter Terraform versions
     ^ column 3

<<< caused by >>>

Finalization of task args for 'ansible.builtin.set_fact' failed.
Origin: /home/ubuntu/azimuth/cloud-azimuth-config/.ansible/collections/ansible_collections/azimuth_cloud/terraform/roles/install/tasks/main.yml:27:3

25
26 - name: Filter Terraform versions
27   ansible.builtin.set_fact:
     ^ column 3

<<< caused by >>>

Error while resolving value for 'terraform_acceptable_versions': object of type 'str' has no attribute 1
Origin: /home/ubuntu/azimuth/cloud-azimuth-config/.ansible/collections/ansible_collections/azimuth_cloud/terraform/roles/install/tasks/main.yml:28:36

26 - name: Filter Terraform versions
27   ansible.builtin.set_fact:
28     terraform_acceptable_versions: >-
                                      ^ column 36

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Task failed: Finalization of task args for 'ansible.builtin.set_fact' failed: Error while resolving value for 'terraform_acceptable_versions': object of type 'str' has no attribute 1"}

PLAY RECAP *********************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0   

N.B: ok: [localhost] => {"ansible_facts": {"terraform_available_versions": "[\n ]"}, "changed": false}

PR incoming to fix, assuming this issue is reproducible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions