Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap_vm_provision: fix var reference to var lookup #59

Merged
merged 1 commit into from
Sep 4, 2024

Conversation

ja9fuchs
Copy link
Contributor

@ja9fuchs ja9fuchs commented Sep 3, 2024

vars[] lookup is preventing nested variables from being evaluated.
The loop breaks when a custom sap_vm_provision_..._host_specifications_dictionary is used that includes nested variables for flexibility.

All other vars lookups in the role had already been changed to use the lookup plugin some time ago.

Input var:

sap_vm_provision_aws_ec2_vs_host_specifications_dictionary:

  # HANA scale-up minimal
  su_min:

    su1hana01: "{{ aws_host_profile.hana_96m_100s.profile_primary }}"
    su1hana02: "{{ aws_host_profile.hana_96m_100s.profile_secondary }}"

Original syntax and result:

- debug:
    var: vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default('su1hana01')].keys() | map('regex_findall', '^sap_.*') | flatten | select() | list
--------------------------------------------------------------------------------------------

ok: [localhost] => 
  ? vars['sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary'][sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default('su1hana01')].keys() | map('regex_findall', '^sap_.*') | flatten | select() | list
  : 'VARIABLE IS NOT DEFINED!: ''ansible.parsing.yaml.objects.AnsibleUnicode object'' has no attribute ''keys''. ''ansible.parsing.yaml.objects.AnsibleUnicode object'' has no attribute ''keys'''

With the fix:

- debug:
    var: lookup('vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary')[sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default('su1hana01')].keys() | map('regex_findall', '^sap_.*') | flatten | select() | list 
--------------------------------------------------------------------------------------------

ok: [localhost] => 
  ? lookup('vars', 'sap_vm_provision_' + sap_vm_provision_iac_platform + '_host_specifications_dictionary')[sap_vm_provision_host_specification_plan][scaleout_origin_host_spec | default('su1hana01')].keys() | map('regex_findall', '^sap_.*') | flatten | select() | list
  : - sap_host_type
    - sap_storage_setup_sid
    - sap_storage_setup_host_type

Copy link
Contributor

@marcelmamula marcelmamula left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ja9fuchs I did not have this issue in any of my runs, but change looks good. LGTM

@berndfinger berndfinger self-requested a review September 4, 2024 07:14
Copy link
Member

@berndfinger berndfinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@berndfinger berndfinger merged commit d90c358 into sap-linuxlab:dev Sep 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants