Class: ProxyAPI::Ansible

Inherits:
Resource
  • Object
show all
Defined in:
app/lib/proxy_api/ansible.rb

Overview

ProxyAPI for Ansible

Constant Summary collapse

PROXY_ERRORS =
[
  Errno::ECONNREFUSED,
  SocketError,
  Timeout::Error,
  Errno::EINVAL,
  Errno::ECONNRESET,
  EOFError,
  Net::HTTPBadResponse,
  Net::HTTPHeaderSyntaxError,
  Net::ProtocolError,
  RestClient::ResourceNotFound
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Ansible

Returns a new instance of Ansible.



6
7
8
9
# File 'app/lib/proxy_api/ansible.rb', line 6

def initialize(args)
  @url = args[:url] + '/ansible/'
  super args
end

Instance Method Details

#all_variablesObject



30
31
32
33
34
35
# File 'app/lib/proxy_api/ansible.rb', line 30

def all_variables
  parse(get('roles/variables'))
rescue *PROXY_ERRORS => e
  raise ProxyException.new(url, e,
                           N_('Unable to get roles/variables from Ansible'))
end

#rolesObject



24
25
26
27
28
# File 'app/lib/proxy_api/ansible.rb', line 24

def roles
  parse(get('roles'))
rescue *PROXY_ERRORS => e
  raise ProxyException.new(url, e, N_('Unable to get roles from Ansible'))
end

#variables(role) ⇒ Object



37
38
39
40
41
42
# File 'app/lib/proxy_api/ansible.rb', line 37

def variables(role)
  parse(get("roles/#{role}/variables"))
rescue *PROXY_ERRORS => e
  raise ProxyException.new(url, e,
                           N_('Unable to get roles/variables from Ansible'))
end