Class: Shelter::Ansible::Inventory

Inherits:
Object
  • Object
show all
Defined in:
lib/ansible/inventory.rb

Overview

Ansible Inventory representation

Instance Method Summary collapse

Constructor Details

#initializeInventory

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_jsonObject



23
24
25
# File 'lib/ansible/inventory.rb', line 23

def to_json
  @inv.to_json
end