# How to get latest versions of roles using galaxy?

**URL:** <https://forum.ansible.com/t/how-to-get-latest-versions-of-roles-using-galaxy/22982>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [November 8, 2016, 7:05pm UTC](https://forum.ansible.com/t/how-to-get-latest-versions-of-roles-using-galaxy/22982 "2016-11-08T19:05:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhomart\_Mukhamejanov](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@Zhomart\_Mukhamejanov](https://forum.ansible.com/u/Zhomart_Mukhamejanov)\
**Post date:** [November 8, 2016, 7:05pm UTC](https://forum.ansible.com/t/how-to-get-latest-versions-of-roles-using-galaxy/22982/1 "2016-11-08T19:05:29Z")

</div>

Currently I’m using a role with it’s dependencies. Author of the role fixed some major bugs but didn’t pushed the release to the [galaxy.ansible.com](http://galaxy.ansible.com).

I want to get latest version of the role and it’s dependencies from github. How can I do it?

---

<div class="post-metadata">

**Author:** ![Zhomart\_Mukhamejanov](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@Zhomart\_Mukhamejanov](https://forum.ansible.com/u/Zhomart_Mukhamejanov)\
**Post date:** [November 8, 2016, 7:38pm UTC](https://forum.ansible.com/t/how-to-get-latest-versions-of-roles-using-galaxy/22982/2 "2016-11-08T19:38:32Z")

</div>

Ok, I’ve created simple script for that.

.roles-list.yml

```auto

- name: lesmyrmidons.mongodb
github: lesmyrmidons/ansible-role-mongodb
- name: Graylog2.graylog-ansible-role
github: Graylog2/graylog-ansible-role

```

./update-roles

```auto

#!/usr/bin/env ruby

require 'yaml'
require 'tmpdir'

root = Pathname.new(File.expand_path( __dir__ ))
roles_list = YAML.load(File.read('.roles-list.yml'))

def command(cmd)
p cmd
system cmd
end

roles_list.each do |role|
puts "\nProcessing #{role['name']}"

url = %(https://github.com/#{role['github']}/archive/master.tar.gz)

dir = Dir.mktmpdir('ansible')
command "cd #{dir}; curl -L #{url} | tar -xf -"

dest = root.join("roles", role['name'])
FileUtils.rm_rf(dest)
FileUtils.mkdir_p(dest)

src = dir
if Dir.new(dir).count == 3
name = Dir.new(dir).to_a.detect { |f| f[0] != '.' }
src = File.join(dir, name)
end

Dir.new(src).each do |f|
next if f == '.' || f == '..'
FileUtils.mv(File.join(src, f), dest)
end

FileUtils.rm_rf(dir)
end

puts "Done!"

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 8, 2016, 8:23pm UTC](https://forum.ansible.com/t/how-to-get-latest-versions-of-roles-using-galaxy/22982/3 "2016-11-08T20:23:06Z")

</div>

ansible-galaxy can do that for you.

Something like this(not tested)

.roles-list.yml  
- src: [https://github.com/lesmyrmidons/ansible-role-mongodb](https://github.com/lesmyrmidons/ansible-role-mongodb)  
&nbsp;&nbsp;&nbsp;name: lesmyrmidons.mongodb  
- src: [https://github.com/Graylog2/graylog-ansible-role](https://github.com/Graylog2/graylog-ansible-role)  
&nbsp;&nbsp;&nbsp;name: Graylog2.graylog-ansible-role

ansible-galaxy install -r .roles-list.yml

Check this link for more information  
[https://docs.ansible.com/ansible/galaxy.html#installing-roles](https://docs.ansible.com/ansible/galaxy.html#installing-roles)
