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

Extra vars yaml issue #26

Closed
przemkalit opened this issue Nov 7, 2024 · 3 comments · Fixed by #27
Closed

Extra vars yaml issue #26

przemkalit opened this issue Nov 7, 2024 · 3 comments · Fixed by #27
Labels
bug Something isn't working

Comments

@przemkalit
Copy link
Contributor

przemkalit commented Nov 7, 2024

Summary

Hey,

There is an issue with exporting the extra vars, it is changing the order of variables in structure to alphabetical. Moreover it sometimes do something like this (probably because of rearranging variables):

image

From what I've tested the culprit is the from_yaml | to_nice_yaml(indent=2)

Issue Type

  • Bug Report

Ansible, Collection, Controller details

Current versions

OS / ENVIRONMENT

RH9

Desired Behavior

Extra vars are properly exported.

Actual Behavior

Source extra vars:

_job_events_use_cases:
  - name: unknown use case
    when:
      matches:
        - unknown use case - no match found with knowledge database
    actions:
      - >-
        just an example
  - name: '!well-known use case, no action needed'
    when:
      matches:
        - 'account_name .+ is not a valid account, cannot get SID'
    actions:
      - >-
        another example

Exported extra_vars:

_job_events_use_cases:
  - actions:
      - >-
        just an example
    name: unknown use case
    when:
      matches:
        - unknown use case - no match found with knowledge database
  - actions:
      - >-
        another example
    name: '!well-known use case, no action needed'
    when:
      matches:
        - account_name .+ is not a valid account, cannot get SID

STEPS TO REPRODUCE

  1. Create JT with long list of extra vars provided in source example
  2. Export the JT with filetree_create
@przemkalit przemkalit added the bug Something isn't working label Nov 7, 2024
@przemkalit
Copy link
Contributor Author

The questions are:

  • should collection preserve the state of extra vars?
  • or should be modified like in the current state?

@przemkalit
Copy link
Contributor Author

I am proposing this change to preserve the state of extra_vars, let me now if you don't mind, then I will create PR.

     extra_vars: {{ template_overrides_dynamic.job_template[current_job_templates_asset_value.name].extra_var
         | default(template_overrides_static.job_template.extra_vars)
         | default(current_job_templates_asset_value.extra_vars)
         | regex_replace('^---\n?', '', multiline=True)
         | indent(width=6, first=False)
         | regex_replace('(^[^:]*): (.*){{', '\\1: !unsafe \\2{{', multiline=True)
      }}

@przemkalit
Copy link
Contributor Author

Please ignore the last message, I will introudce PR with sort_keys=False in to_nice_yaml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant