ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
13.98k stars 3.41k forks source link

Inventory for schedules in inventory sources/job templates causes import to fail #13137

Open ArtsiomMusin opened 1 year ago

ArtsiomMusin commented 1 year ago

Please confirm the following

Bug Summary

This is related to export/import PR I opened here #13090 image

As discussed with @jbradberry in this comment(https://github.com/ansible/awx/pull/13132#issuecomment-1297150532), it might be a real bug related to the launch option or something. This is mainly affecting export/import functionality for awx cli.

AWX version

Tower 3.8.6, AAP 4.2.1

Select the relevant components

Installation method

openshift

Modifications

no

Ansible version

No response

Operating system

No response

Web browser

No response

Steps to reproduce

Two scenarios where this issue occurs

Steps to reproduce via API:

  1. Create a new schedule for inventory source/job template
  2. Try to PATCH it via API call with some inventory id

Result: image

Steps to reproduce via awx cli:

  1. Create a new schedule for inventory source/job template
  2. Export this schedule via awx cli
  3. Remove the schedule
  4. Patch your awxkit with changes in #13132
  5. Import the schedule

Result: Failed with this error:

/api/v2/schedules/ "abc1_schedule_inv_source": Bad Request (400) received - {'inventory': ['Field is not allowed on launch.']}.

Expected results

Import for schedules created for inventory sources/job templates is working fine

Actual results

Above in the steps to reproduce

Additional information

No response

jbradberry commented 1 year ago

@ArtsiomMusin Can you please clarify this?

Tower 3.8.6, AAP 4.2.1

What is the involvement of 3.8.6 in all of this? Version 4.2.1 is a version of Controller, which is the project formerly known as Tower. The associated version of AAP for Controller 4.2.1 would be 2.2 something.

ArtsiomMusin commented 1 year ago

yes, I just realized Tower is not related here. We just have Tower and AAP deployed on the same env. Anyway, we can ignore Tower.

For AAP, I took the version from here. Not very familiar 4.2.1 is the version of controller or AAP itself. Sorry for inaccuracy. :sweat_smile: image

maximerobine commented 1 year ago

Hello, i've the exact same problem, i can't import inventory sources that are scheduled on my new AWX instance (21.10.2). I've tried the API and the awx.awx.import module, i'm always having : Bad Request (400) received - {'inventory': ['Field is not allowed on launch.']}. Am i doing something wrong or is this a bug ?

jbradberry commented 1 year ago

@maximerobine I'm pretty sure it is a bug, having to do with the recent expansion in "prompt on launch" capabilities.

ArtsiomMusin commented 1 year ago

I'd love to fix that as this is one missing thing for us during export/import activities. If someone can guide me to the right path to fix that, I will contribute here.

Here just some findings from my side so far. I saw this issue before and I tried to add a small fix(just a kind of hack) some time ago for awxkit: image Basically just to skip that "prompt on launch" field from a schedule object during export. So on import schedule would be added correctly. It's not very good but worked well...

Also I haven't noticed why this field is required for schedules at all. Is this a part of some new upcoming feature? Wondering if it was added for schedules by a mistake or no longer needed... Can we maybe remove this field from the schedule table? @AlanCoding could you help here to answer as I saw in git history you are the author of those changes?

jbradberry commented 1 year ago

@ArtsiomMusin we have a dev already assigned to this. This bug comes up in more contexts than just import/export.

ArtsiomMusin commented 1 year ago

Great! Will wait for a fix then. Thanks

maximerobine commented 1 year ago

Hello, is there any news on this ? I've encountered a new problem that looks related to this issue. When I import a job_template (freshly exported from another AWX), I get the following error : Bad Request (400) received - {'inventory': ['Must either set a default value or ask to prompt on launch.']}. But when i look in the json of the job template, there clearly is an inventory defined :

        ...
        "inventory": {
            "name": "localhost",
            "organization": {
                "name": "Default",
                "type": "organization"
            },
            "type": "inventory"
        },
        ...

Both AWX are in the same version (22.0.0) and using awx.awx collection version 22.0.0

maximerobine commented 1 year ago

About my last message, the user i was using to import jobs didnt have sufficient permissions on my localhost inventory. Thus, it is not related at all to this issue, sorry for the inconvenience.