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

awx.awx.organization fails when new_name is set and organisation already got renamed #15572

Open
5 of 11 tasks
bartowl opened this issue Oct 3, 2024 · 1 comment
Open
5 of 11 tasks
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug

Comments

@bartowl
Copy link

bartowl commented Oct 3, 2024

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX is open source software provided for free and that I might not receive a timely response.
  • I am NOT reporting a (potential) security vulnerability. (These should be emailed to [email protected] instead.)

Bug Summary

The issue happens, when awx.awx.organization is called twice with both name and new_name attribute.
First time, the Organization gets renamed properly, but during second run, instead of the task reporting plain 'ok' as no change is needed since the organisation is already renamed it shows following error:

Unable to create organization new_name: {'name': ['Organization with this Name  already exists.']}

AWX version

24.6.1

Select the relevant components

  • UI
  • UI (tech preview)
  • API
  • Docs
  • Collection
  • CLI
  • Other

Installation method

N/A

Modifications

no

Ansible version

2.15.12

Operating system

Linux

Web browser

Chrome

Steps to reproduce

execute twice following task:

- name: re-name organization
  awx.awx.organization:
    name: Default
    new_name: new_name

Expected results

I would expect this task reports OK, as the change has already been done (for the second and following runs)

Actual results

I get an error:

Unable to create organization Main: {'name': ['Organization with this Name already exists.']}

Additional information

This problem seems to be an easy fix in

organization = module.get_one('organizations', name_or_id=name, check_exists=(state == 'exists'))

just change

    organization = module.get_one('organizations', name_or_id=name, check_exists=(state == 'exists'))

to

    organization = module.get_one('organizations', name_or_id=name, check_exists=(state == 'exists'))
    # check if organization already got renamed
    if new_name and not organization:
      organization = module.get_one('organizations', name_or_id=new_name, check_exists=(state == 'exists'))

PS. similar issues may affect other modules having new_name attribute. Should I provide PR?

@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug community labels Oct 3, 2024
@bartowl
Copy link
Author

bartowl commented Oct 3, 2024

Forgot to mention, I use version awx.awx:24.6.1 of the collection.

Main question is - is this wanted behaviour, or a bug. If this is indeed a bug I could provide PR against this and potentialy other modules having new_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community component:awx_collection issues related to the collection for controlling AWX needs_triage type:bug
Projects
None yet
Development

No branches or pull requests

1 participant