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.
I want to get latest version of the role and it’s dependencies from github. How can I do it?
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.
I want to get latest version of the role and it’s dependencies from github. How can I do it?
Ok, I’ve created simple script for that.
.roles-list.yml
- name: lesmyrmidons.mongodb
github: lesmyrmidons/ansible-role-mongodb
- name: Graylog2.graylog-ansible-role
github: Graylog2/graylog-ansible-role
./update-roles
#!/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!"
ansible-galaxy can do that for you.
Something like this(not tested)
.roles-list.yml
- src: https://github.com/lesmyrmidons/ansible-role-mongodb
name: lesmyrmidons.mongodb
- src: https://github.com/Graylog2/graylog-ansible-role
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