Class: Moose::Inventory::Operations::QueryInventory::HostQueries
- Inherits:
-
BaseQuery
- Object
- BaseQuery
- Moose::Inventory::Operations::QueryInventory::HostQueries
show all
- Defined in:
- lib/moose_inventory/operations/query_inventory/host_queries.rb
Overview
Host-focused read queries.
Instance Method Summary
collapse
Methods inherited from BaseQuery
#initialize
Instance Method Details
#get_hosts(names:) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/moose_inventory/operations/query_inventory/host_queries.rb', line 9
def get_hosts(names:)
names.each_with_object({}) do |name, results|
host = context.find_host(name)
next if host.nil?
results[host.name.to_sym] = host_data(host)
end
end
|
#list_host_vars(names:, ansible:) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/moose_inventory/operations/query_inventory/host_queries.rb', line 27
def list_host_vars(names:, ansible:)
return ansible_host_vars(names.first) if ansible
names.each_with_object({}) do |name, results|
host = context.find_host(name)
next if host.nil?
results[name.to_sym] = variables_hash(host.hostvars_dataset)
end
end
|
#list_hosts(filters: {}) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/moose_inventory/operations/query_inventory/host_queries.rb', line 18
def list_hosts(filters: {})
dataset = filtered_hosts_dataset(filters)
return {} if dataset.nil?
dataset.order(:id).all.to_h do |host|
[host.name.to_sym, host_data(host)]
end
end
|