Class: AnsibleSpec::AnsibleCfg
- Inherits:
-
Object
- Object
- AnsibleSpec::AnsibleCfg
- Defined in:
- lib/ansible_spec/load_ansible.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get(section, key) ⇒ Object
-
#initialize ⇒ AnsibleCfg
constructor
A new instance of AnsibleCfg.
- #roles_path ⇒ Object
Constructor Details
#initialize ⇒ AnsibleCfg
Returns a new instance of AnsibleCfg.
524 525 526 |
# File 'lib/ansible_spec/load_ansible.rb', line 524 def initialize @cfg = self.class.load_ansible_cfg end |
Class Method Details
.find_ansible_cfgs ⇒ Object
534 535 536 537 538 539 540 541 542 543 |
# File 'lib/ansible_spec/load_ansible.rb', line 534 def find_ansible_cfgs() files = [] ["/etc/ansible/ansible.cfg", File.("~/.ansible.cfg"), "./ansible.cfg", ENV["ANSIBLE_CFG"], ].each do |f| files << f if f and File.exists? f end end |
.load_ansible_cfg ⇒ Object
545 546 547 548 549 550 551 |
# File 'lib/ansible_spec/load_ansible.rb', line 545 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 |
Instance Method Details
#get(section, key) ⇒ Object
554 555 556 557 558 559 560 561 |
# File 'lib/ansible_spec/load_ansible.rb', line 554 def get(section, key) s = @cfg[section] if s return s[key] else return nil end end |
#roles_path ⇒ Object
528 529 530 531 |
# File 'lib/ansible_spec/load_ansible.rb', line 528 def roles_path rp = (self.get('defaults', 'roles_path') or '').split(':') rp << 'roles' # Roles is always searched end |