Class: AnsibleGalaxy::Roles::Private

Inherits:
Object
  • Object
show all
Includes:
Contracts
Defined in:
lib/ansible_galaxy/roles.rb

Overview

Authenticated Access to Roles

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Private

Returns a new instance of Private.



13
14
15
16
17
18
# File 'lib/ansible_galaxy/roles.rb', line 13

def initialize(options = {})
  username = options.fetch 'username', ENV['ANSIBLE_GALAXY_USERNAME']
  password = options.fetch 'password', ENV['ANSIBLE_GALAXY_PASSWORD']
  @auth = "#{username}:#{password}"
  @my = AnsibleGalaxy::Me.new(options)
end

Instance Method Details

#find(name) ⇒ Object



21
22
23
# File 'lib/ansible_galaxy/roles.rb', line 21

def find(name)
  @my.roles.select { |role| role['name'] == name }
end

#find_id(name) ⇒ Object



26
27
28
# File 'lib/ansible_galaxy/roles.rb', line 26

def find_id(name)
  find(name).first['id']
end

#refresh(names) ⇒ Object



31
32
33
34
35
# File 'lib/ansible_galaxy/roles.rb', line 31

def refresh(names)
  Typhoeus::Hydra.new.tap do |hydra|
    names.each { |name| hydra.queue refresh_role name }
  end.run
end