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

Support for Ansible Galaxy #286

Closed
tersmitten opened this issue Oct 22, 2014 · 15 comments
Closed

Support for Ansible Galaxy #286

tersmitten opened this issue Oct 22, 2014 · 15 comments
Labels
good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs

Comments

@tersmitten
Copy link

There's a REST API available at.

@espadrine
Copy link
Member

All this information is greatly appreciated!

Lacking knowledge about Ansible, however, it is difficult for me to understand which kind of badge I can provide.

@tersmitten
Copy link
Author

How thoughtful of me :-) I will look into it...

@igormukhingmailcom
Copy link

Hi, @espadrine!
For example, I have some ansible role at https://github.com/ansible-roles/ansible-role-sublimetext3_packagecontrol and published at Galaxy https://galaxy.ansible.com/list#/roles/3078

So, 3078 is the role ID that used in API calls.

I think there will be cool if next badges for ansible will be available at shields.io:

Badge Name API Call URL Keys used to generate result Result / Badge Value example
Role name https://galaxy.ansible.com/api/v1/roles/3078/ summary_fields->owner->username + '.' + name igor_mukhin.sublimetext3_packagecontrol
Minimum ansible version https://galaxy.ansible.com/api/v1/roles/3078/ min_ansible_version 1.4
Versions count (not sure this badge will be popular, but who knows) https://galaxy.ansible.com/api/v1/roles/3078/versions/ count 3
Latest version https://galaxy.ansible.com/api/v1/roles/3078/versions/ first(results)->name v0.2.0

To generate all this badges we need get only role ID from user. Or even just role's galaxy URL and then automatically extract ID from hash.

@espadrine
Copy link
Member

Thanks a lot for this information! That is tremendously helpful.

I notice that they send a cookie (Set-Cookie: sessionid=oxd81rvw70noo42xqwg594t6ngc8ncsq; expires=Mon, 25-May-2015 19:16:28 GMT; httponly; Max-Age=1209600; Path=/), that is a bit odd. Otherwise, it all seems straightforward.

@igormukhingmailcom
Copy link

@espadrine Don't think that cookies matter something.
You can just get information and not care about cookies.

Try wget -qO - https://galaxy.ansible.com/api/v1/roles/3078/versions/.

@espadrine espadrine added the needs-upstream-help Not actionable without help from a service provider label May 13, 2015
@igormukhingmailcom
Copy link

@espadrine Hi. How can I help you to force some progress on this?

@espadrine
Copy link
Member

I tried making the first one, with this kind of style:

I am unsure of whether that suits the notion of "role" that users are familiar with, or how easy it is to figure out where to find the role id.

espadrine added a commit that referenced this issue Sep 7, 2015
@igormukhingmailcom
Copy link

Oh, cool :)

Role Id assigned to role once it added to galaxy.
For example this is list of my roles: https://galaxy.ansible.com/list#/users/9737

@smiller171
Copy link

@igormukhingmailcom does getting the information like this still work? I can't find IDs on my roles.

@tersmitten
Copy link
Author

Ansible galaxy 2 uses "name based" urls now, but old urls should be
redirected.

On Friday, 19 February 2016, Scott Miller [email protected] wrote:

@igormukhingmailcom https://github.com/igormukhingmailcom does getting
the information like this still work? I can't find IDs on my roles.


Reply to this email directly or view it on GitHub
#286 (comment).

@smiller171
Copy link

Sounds like we probably need a PR to fix this functionality then

@danvaida
Copy link

@smiller171 here's a one-liner for finding your role's ID once it's on Galaxy:

$ ansible-galaxy info YourUser.RoleName | grep -E 'id: [0-9]' | awk {'print $2'}

This works on Ansible 2.2.2.0 but I recon it's working on older versions, too.

@paulmelnikow paulmelnikow added service-badge Accepted and actionable changes, features, and bugs and removed needs-upstream-help Not actionable without help from a service provider labels Oct 12, 2017
@andy-maier
Copy link

Since this issue comes up at the top of the result list when searching for how to get a badge that shows the latest version of a collection on Ansible Galaxy, I'll post our solution for that.

Ansible Galaxy returns the latest version of a collection using an HTTP GET on
https://galaxy.ansible.com/api/v2/collections/{NS}/{COLL}/ as follows:

{
    . . .
    "latest_version": {
        "version": "1.0.0-dev1",
    }
}

That allows using the dynamic badge creation feature of shields.io, e.g. in Markdown syntax:

![Version on Galaxy](https://img.shields.io/badge/dynamic/json?style=flat&label=galaxy&prefix=v&url=https://galaxy.ansible.com/api/v2/collections/ibm/ibm_zos_core/&query=latest_version.version)

Resulting in this badge:

Version on Galaxy

@calebcartwright
Copy link
Member

Thanks for sharing @andy-maier! Given the above, it seems like we should be able to add a native version badge if you or anyone else would be interested in submitting a PR

@IronTooch
Copy link

IronTooch commented Jan 29, 2022

For anyone who finds this search, you can use the API to query for a role directly. E.g.

https://galaxy.ansible.com/api/v1/roles/?search=myrole

And once you get the role ID, you can use this to get the downloads count:

https://img.shields.io/badge/dynamic/json?color=blueviolet&label=Galaxy%20Downloads&query=%24.download_count&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2FROLEID%2F%3Fformat%3Djson

E.g.
https://galaxy.ansible.com/api/v1/roles/?search=olivetin
image
Ansible Role URL is: https://img.shields.io/ansible/role/57702

Galaxy Downloads URL is: https://img.shields.io/badge/dynamic/json?color=blueviolet&label=Galaxy%20Downloads&query=%24.download_count&url=https%3A%2F%2Fgalaxy.ansible.com%2Fapi%2Fv1%2Froles%2F57702%2F%3Fformat%3Djson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

No branches or pull requests

10 participants