class AnsibleSpec::AnsibleCfg

Public Class Methods

find_ansible_cfgs() click to toggle source
# File lib/ansible_spec/load_ansible.rb, line 593
def find_ansible_cfgs()
  files = []
  ["/etc/ansible/ansible.cfg",
   File.expand_path("~/.ansible.cfg"),
   "./ansible.cfg",
   ENV["ANSIBLE_CFG"],
  ].each do |f|
    files << f if f and File.exists? f
  end
end
load_ansible_cfg() click to toggle source
# File lib/ansible_spec/load_ansible.rb, line 604
def load_ansible_cfg()
  cfg = IniFile.new
  self.find_ansible_cfgs.each do |file|
    cfg = cfg.merge(IniFile.new :filename => file)
  end
  cfg.to_h
end
new() click to toggle source
# File lib/ansible_spec/load_ansible.rb, line 583
def initialize
  @cfg = self.class.load_ansible_cfg
end

Public Instance Methods

get(section, key) click to toggle source
# File lib/ansible_spec/load_ansible.rb, line 613
def get(section, key)
  s = @cfg[section]
  if s
    return s[key]
  else
    return nil
  end
end
roles_path() click to toggle source
# File lib/ansible_spec/load_ansible.rb, line 587
def roles_path
  rp = (self.get('defaults', 'roles_path') or '').split(':')
  rp << 'roles'  # Roles is always searched
end