forked from Obmondo/LinuxAid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinuxaid_enc.rb
More file actions
executable file
·38 lines (31 loc) · 848 Bytes
/
linuxaid_enc.rb
File metadata and controls
executable file
·38 lines (31 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/opt/puppetlabs/puppet/bin/ruby
# frozen_string_literal: true
require 'yaml'
CERTNAME = ARGV[0]
MAX_TAGS = 10
DEFAULT_HIERA_BRANCH = 'main'
OBMONDO_MONITOR = true
SUBSCRIPTION = false
HIERA_DATADIR = '../../hiera-data'
TAGS_FILE = HIERA_DATADIR + '/' + DEFAULT_HIERA_BRANCH + '/tags.yaml'
# TODO: add support for regex in array list
def find_keys_for_host(data, certname)
data.select { |key, hosts| hosts.include?(certname) }.keys
end
begin
LIST_OF_TAGS = YAML.load_file(TAGS_FILE)
TAG_KEYS = find_keys_for_host(LIST_OF_TAGS, CERTNAME)
rescue
TAG_KEYS = []
end
parameters = {
'node_name' => CERTNAME,
'obmondo_monitor' => OBMONDO_MONITOR,
'hiera_datapath' => DEFAULT_HIERA_BRANCH,
'obmondo_tags' => TAG_KEYS,
'subscription' => SUBSCRIPTION,
}
output = {
'parameters' => parameters
}
puts YAML.dump(output)