Skip to content

Commit 8f89b65

Browse files
committed
feat: let opensource user add tag of their own
sample tags.yaml ```yaml --- kubernetes-demo: - web238.example.intern - web239.example.intern - web240.example.intern - web241.example.intern ```
1 parent 34bb27b commit 8f89b65

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

linuxaid_enc.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,21 @@
88
DEFAULT_HIERA_BRANCH = 'main'
99
OBMONDO_MONITOR = true
1010
SUBSCRIPTION = false
11-
TAG_KEYS = []
11+
HIERA_DATADIR = ../../hiera-data
12+
TAGS_FILE = HIERA_DATADIR + '/' + DEFAULT_HIERA_BRANCH + '/tags.yaml'
13+
14+
# TODO: add support for regex in array list
15+
def find_keys_for_host(data, certname)
16+
data.select { |key, hosts| hosts.include?(certname) }.keys
17+
end
18+
19+
begin
20+
LIST_OF_TAGS = YAML.load_file(TAGS_FILE)
21+
TAG_KEYS = find_keys_for_host(LIST_OF_TAGS, CERTNAME)
22+
rescue
23+
warn 'No tags file found at => ' + TAGS_FILE
24+
TAG_KEYS = []
25+
end
1226

1327
parameters = {
1428
'node_name' => CERTNAME,

0 commit comments

Comments
 (0)