Class: Shelter::Ansible::Inventory
- Inherits:
-
Object
- Object
- Shelter::Ansible::Inventory
- Defined in:
- lib/ansible/inventory.rb
Overview
Ansible Inventory representation
Instance Method Summary collapse
- #add_group_vars(group, vars) ⇒ Object
- #add_server(group, ip, vars: {}) ⇒ Object
-
#initialize ⇒ Inventory
constructor
A new instance of Inventory.
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ Inventory
Returns a new instance of Inventory.
7 8 9 |
# File 'lib/ansible/inventory.rb', line 7 def initialize @inv = {} end |
Instance Method Details
#add_group_vars(group, vars) ⇒ Object
11 12 13 14 |
# File 'lib/ansible/inventory.rb', line 11 def add_group_vars(group, vars) @inv[group] ||= { hosts: [], vars: {} } @inv[group][:vars].merge! vars end |
#add_server(group, ip, vars: {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/ansible/inventory.rb', line 16 def add_server(group, ip, vars: {}) @inv[group] ||= { hosts: [], vars: {} } @inv[group][:hosts] << ip @inv[group][:vars].merge!(vars) end |
#to_json ⇒ Object
23 24 25 |
# File 'lib/ansible/inventory.rb', line 23 def to_json @inv.to_json end |