-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix for Specifying unified_job_template as ID doesn't work #15255
base: devel
Are you sure you want to change the base?
Conversation
…n't work ansible#14458 Summary: set unified_job_template as value for key id in search_fields if unified_job_template is digit Signed-off-by: Павел Павлов <[email protected]>
@@ -262,7 +262,10 @@ def main(): | |||
search_fields['organization'] = module.resolve_name_to_id('organizations', organization) | |||
unified_job_template_id = None | |||
if unified_job_template: | |||
search_fields['name'] = unified_job_template | |||
if unified_job_template.isdigit(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module.get_one
has a parameter called name_or_id
. Might be better to use that instead
here is an example from a different module
awx/awx_collection/plugins/modules/host.py
Line 105 in 63e82aa
host = module.get_one('hosts', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'inventory': inventory_id}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, thank you for review! I changed code and it use name_or_id now
…n't work ansible#14458 Summary: fix after review, using name_or_id=id parameter Signed-off-by: Павел Павлов <[email protected]>
@@ -262,8 +262,7 @@ def main(): | |||
search_fields['organization'] = module.resolve_name_to_id('organizations', organization) | |||
unified_job_template_id = None | |||
if unified_job_template: | |||
search_fields['name'] = unified_job_template | |||
unified_job_template_id = module.get_one('unified_job_templates', **{'data': search_fields})['id'] | |||
unified_job_template_id = module.get_one('unified_job_templates', name_or_id=id, **{'data': search_fields})['id'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name_or_id=id, -- id
isn't a defined variable here
instead I think you want name_or_id=unified_job_template
Also, since search_fields
is no longer defined, we don't need to include **{'data': search_fields}
also can you provide steps on how you are verifying the change? |
…n't work ansible#14458 Summary: changes after review name_or_id=id changed to name_or_id=unified_jod_template Signed-off-by: Павел Павлов <[email protected]>
…n't work ansible#14458 Summary: remove **{'data': search_fields} Signed-off-by: Павел Павлов <[email protected]>
SUMMARY
related #14458
Summary: set unified_job_template as value for key id in search_fields if
unified_job_template is digit
ISSUE TYPE
COMPONENT NAME
AWX VERSION
ADDITIONAL INFORMATION
This issue described at #14458