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.
584 585 586 |
# File 'lib/ansible_spec/load_ansible.rb', line 584 def initialize @cfg = self.class.load_ansible_cfg end |
Class Method Details
.find_ansible_cfgs ⇒ Object
594 595 596 597 598 599 600 601 602 603 |
# File 'lib/ansible_spec/load_ansible.rb', line 594 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
605 606 607 608 609 610 611 |
# File 'lib/ansible_spec/load_ansible.rb', line 605 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
614 615 616 617 618 619 620 621 |
# File 'lib/ansible_spec/load_ansible.rb', line 614 def get(section, key) s = @cfg[section] if s return s[key] else return nil end end |
#roles_path ⇒ Object
588 589 590 591 |
# File 'lib/ansible_spec/load_ansible.rb', line 588 def roles_path rp = (self.get('defaults', 'roles_path') or '').split(':') rp << 'roles' # Roles is always searched end |