Skip to content

Support for Ansible Galaxy #286

Closed
Closed

Description

@tersmitten

There's a REST API available at.

Activity

  1. espadrine commented on Oct 22, 2014

    @espadrine
    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.

  2. tersmitten commented on Oct 29, 2014

    @tersmitten
    Author

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

  3. igormukhingmailcom commented on May 5, 2015

    @igormukhingmailcom

    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.

  4. espadrine commented on May 11, 2015

    @espadrine
    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.

  5. igormukhingmailcom commented on May 12, 2015

    @igormukhingmailcom

    @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/.

  6. igormukhingmailcom commented on Sep 6, 2015

    @igormukhingmailcom

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

  7. espadrine commented on Sep 7, 2015

    @espadrine
    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.

  8. added a commit that references this issue on Sep 7, 2015
  9. igormukhingmailcom commented on Sep 7, 2015

    @igormukhingmailcom

    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

  10. smiller171 commented on Feb 19, 2016

    @smiller171

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

  11. tersmitten commented on Feb 19, 2016

    @tersmitten
    Author

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

    On Friday, 19 February 2016, Scott Miller notifications@github.com 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).

  12. smiller171 commented on Feb 19, 2016

    @smiller171

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

  13. danvaida commented on Mar 14, 2017

    @danvaida

    @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.

  14. added
    service-badgeNew or updated service badge
    and removed
    needs-upstream-helpNot actionable without help from a service provider
    on Oct 12, 2017
  15. andy-maier commented on Nov 27, 2020

    @andy-maier

    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

  16. calebcartwright commented on Nov 27, 2020

    @calebcartwright
    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

  17. IronTooch commented on Jan 29, 2022

    @IronTooch

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions