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

Added support to collection for named urls #14205

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

john-westcott-iv
Copy link
Member

SUMMARY

With this change awx.awx colleciton modules can used named URLs. For example:

---
- name: Test a named URL
  hosts: localhost
  connection: local
  gather_facts: False
  tasks:
    - name: Create a job template
      awx.awx.job_template:
        name: named_url_test
        job_type: "run"
        inventory: "Demo Inventory++Default"
        project: "Demo Project++Default"
        playbook: "hello_world.yml"
        credentials:
          - "Demo Credential++Machine+ssh++"
        state: "present"
ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • Collection
AWX VERSION

ADDITIONAL INFORMATION

@github-actions github-actions bot added the component:awx_collection issues related to the collection for controlling AWX label Jul 5, 2023
@john-westcott-iv john-westcott-iv changed the title Added support to collection for named urls [WIP] Added support to collection for named urls Jul 5, 2023
@AlanCoding
Copy link
Member

Organizations are vanilla name-unique. So you would have to do organization: Default++? I don't know if this is useful or intended...

@sean-m-sullivan
Copy link
Contributor

Vanilla names should still work, What I've been trying to do is make it so it takes the output of export out of the box, and using that as the metric, if we could an output for export to put out the named urls... well that would be /chefskiss

@ericzolf
Copy link

ericzolf commented Jul 6, 2023

It might make sense to make it clear that get_one remains the entry point by prefixing the two new functions with underscore? i.e. _get_by_name and _get_by_named_url

@john-westcott-iv
Copy link
Member Author

I found a bug playing around with this and will be providing an update to the code.

@john-westcott-iv
Copy link
Member Author

@AlanCoding items with just a single named reference (i.e. Orgs) would skip the named reference task in this current implementation. Since a named reference is a pretty simple git we could remove the check on ++ and always try the GET for a named reference first and then fall back to the lookup method. This should be much easier in the new implementation of the code. Let me know if you think its worth it, I'm currently debating if it would be "faster" since we already say to use "Name" but that would only apply to named lookups where they only have one part for the name so maybe not?

@john-westcott-iv john-westcott-iv changed the title [WIP] Added support to collection for named urls Added support to collection for named urls Jul 6, 2023
@john-westcott-iv john-westcott-iv force-pushed the named_urls branch 3 times, most recently from caca1b3 to a2f8846 Compare July 6, 2023 15:13
@AlanCoding
Copy link
Member

How should we document features like this? We have plugin-level docs with examples, but because this is general that's not effective. For stuff like authentication, there are parameters that correspond to features so those options can be documented on their own.

To me that leaves the README. Maybe we need a general feature overview that covers stuff like this. Otherwise, how do users find it?

@john-westcott-iv
Copy link
Member Author

@AlanCoding I did open an issue for updating all of the docs to say: "name, ID or named URL" #14208. Which would help but yea, we could also do something in the root readme.

@john-westcott-iv
Copy link
Member Author

I put a place holder in the readme which will need a last minute replacement once we know what version this will be released with.

@@ -68,6 +68,7 @@ Notable releases of the `awx.awx` collection:
- 7.0.0 is intended to be identical to the content prior to the migration, aside from changes necessary to function as a collection.
- 11.0.0 has no non-deprecated modules that depend on the deprecated `tower-cli` [PyPI](https://pypi.org/project/ansible-tower-cli/).
- 19.2.1 large renaming purged "tower" names (like options and module names), adding redirects for old names
- X.X.X added support of named URLs to all modules. Anywhere that previously accepted name or id can also support named URLs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it's either going to be 22.5.1 or 22.6.0 or 23.0.0?

@@ -421,7 +443,6 @@ def get_one(self, endpoint, name_or_id=None, allow_none=True, check_exists=False
self.fail_wanted_one(response, endpoint, new_kwargs.get('data'))

if check_exists:
name_field = self.get_name_field_from_endpoint(endpoint)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so surprised no linter could pick this up

Copy link
Member

@AlanCoding AlanCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems complete, I just want to look for some feedback that people see this and use it and it doesn't mess them up.

@jay-steurer jay-steurer merged commit 5a63533 into ansible:devel Jul 27, 2023
14 checks passed
djyasin pushed a commit to djyasin/awx that referenced this pull request Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:awx_collection issues related to the collection for controlling AWX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants