Skip to content

Commit

Permalink
Bugfix/cluster info outputs (#115)
Browse files Browse the repository at this point in the history
* fix return value from cluster info tasks

* update info test to check for returned content

* add changelog

* bugfixes

* update simulator checks

* fix clusters returning empty data

* remove debug statement
  • Loading branch information
mikemorency authored Dec 11, 2024
1 parent 9e5a5d6 commit b3ea45c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/114-update-cluster-info-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- info - added test checks to make sure content is returned when requested
11 changes: 8 additions & 3 deletions roles/info/tasks/cluster_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
password: "{{ info_password }}"
port: "{{ info_port | d(omit) }}"
validate_certs: "{{ info_validate_certs | default(omit) }}"
cluster: "{{ _cluster_name }}"
cluster: "{{ _cluster.name }}"
schema: vsphere
properties:
- name
- configuration.dasConfig.enabled
- summary.totalCpu
loop: "{{ __clusters.value }}"
loop_control:
loop_var: _cluster_name
loop_var: _cluster
register: __clusters_info
tags:
- cluster
Expand All @@ -50,9 +50,14 @@
loop: "{{ info_datacenters }}"
loop_control:
loop_var: _dc_name
register: __clusters_info
register: __dc_clusters_info
tags:
- cluster
# If we register the task above directly to __clusters_info,
# it sets the variable even if the block is skipped.
- name: Map Cluster Info To Correct Variable
ansible.builtin.set_fact:
__clusters_info: "{{ __dc_clusters_info }}"

- name: Write Cluster Results To File
when: info_cluster_file
Expand Down
2 changes: 1 addition & 1 deletion roles/info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
license: "{{ __license.licenses | default([]) }}"
appliance: "{{ __appliance.appliance | default({}) }}"
guest: "{{ __guests.guests | default([]) }}"
cluster: "{{ _clusters_info.results | default([]) | map(attribute='clusters') }}"
cluster: "{{ __clusters_info.results | default([]) | map(attribute='clusters') }}"
storage: "{{ __storage_policy.spbm_profiles | default([]) }}"
when: info_expose_outputs_as_variable
6 changes: 6 additions & 0 deletions tests/integration/targets/vmware_ops_info_test/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
- vmware_ops_info_outputs.guest is defined
- vmware_ops_info_outputs.cluster is defined
- vmware_ops_info_outputs.storage is defined

- (vmware_ops_info_outputs.appliance.keys() | length > 0) == info_appliance
- (vmware_ops_info_outputs.license | length > 0) == info_license
- (vmware_ops_info_outputs.guest | length > 0) == info_guest
- (vmware_ops_info_outputs.cluster | length > 0) == info_cluster
- (vmware_ops_info_outputs.storage | length > 0) == info_storage
7 changes: 2 additions & 5 deletions tests/integration/targets/vmware_ops_info_test/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ vmware_ops_validate_certs: false
vmware_ops_port: "9000"

prepare_rest_mock_file: "{{ playbook_dir }}/mock.json"
# workaround till simulator fixed in the next release-
# check doc in cloud.vmware_ops/roles/cluster_settings
# for pyvmomi current version limitation
info_cluster: false
info_license: true
info_cluster: true
info_license: false
info_appliance: false
info_guest: false
info_storage: false

0 comments on commit b3ea45c

Please sign in to comment.