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
457 458 459 |
# File 'lib/ansible_spec/load_ansible.rb', line 457 def initialize @cfg = self.class.load_ansible_cfg end |
Class Method Details
.find_ansible_cfgs ⇒ Object
467 468 469 470 471 472 473 474 475 476 |
# File 'lib/ansible_spec/load_ansible.rb', line 467 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
478 479 480 481 482 483 484 |
# File 'lib/ansible_spec/load_ansible.rb', line 478 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
487 488 489 490 491 492 493 494 |
# File 'lib/ansible_spec/load_ansible.rb', line 487 def get(section, key) s = @cfg[section] if s return s[key] else return nil end end |
#roles_path ⇒ Object
461 462 463 464 |
# File 'lib/ansible_spec/load_ansible.rb', line 461 def roles_path rp = (self.get('defaults', 'roles_path') or '').split(':') rp << 'roles' # Roles is always searched end |