redhat-cop / aap_configuration_extended

providing extended functionality that is not in aap_configuration
GNU General Public License v3.0
0 stars 3 forks source link

Export/Import survey multiple choice issue #8

Open przemkalit opened 4 weeks ago

przemkalit commented 4 weeks ago

Summary

I've discovered that when a survey with multiple-choice questions is exported with JT/WF and then imported, the multiple-choice gets broken - it has only one choice.

Issue Type

Ansible, Collection, Controller details

ansible --version

ansible [core 2.15.8]

ansible-galaxy collection list
Collection                     Version
------------------------------ -------
ansible.controller                        4.5.10
infra.controller_configuration 2.9.0

OS / ENVIRONMENT

RH 9.4

Desired Behavior

Survey has a list of choices:

A
B
C
D

Actual Behavior

Survey has a one choice:

A/nB/nC/nD

STEPS TO REPRODUCE

Remark: the object with survey must be migrated from ATP to AAP using upgrade method.

  1. Create JT with survey on ATP with multiple choice question, add at least two answers.
  2. Upgrade ATP to AAP
  3. Export the JT
  4. Import the JT
przemkalit commented 3 weeks ago

Ok the problem is related to survey that are migrated from ansible tower, in the UI survey is working after migration but in the API is in the old state. Closing the issue.

przemkalit commented 2 weeks ago

Reopen it, we identified that the issue is produced by this part of the code: templates/job_template.j2 (the same for WF)

{% set survey_spec_contents = query(controller_api_plugin, current_job_templates_asset_value.related.survey_spec,
                                    host=controller_hostname, oauth_token=controller_oauthtoken, verify_ssl=controller_validate_certs)[0] |
                                    from_yaml | to_nice_yaml(indent=2,width=500) | regex_replace("\n\n[ ]*", "\\\\n") | indent(width=6, first=False) | replace("'{{", "!unsafe \'{{") | replace("^$", "") | replace("$encrypted$", "") | replace("'", '"')
-%}

Somehow saving to file, modify the survey in a way that when it is loaded with filetree_read and dispatch, it import into controller multiselect objects like in the first post.