summaryrefslogtreecommitdiff
path: root/modules/profiles/files/node-classifier.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/profiles/files/node-classifier.py')
-rw-r--r--modules/profiles/files/node-classifier.py44
1 files changed, 0 insertions, 44 deletions
diff --git a/modules/profiles/files/node-classifier.py b/modules/profiles/files/node-classifier.py
deleted file mode 100644
index 7fc096f..0000000
--- a/modules/profiles/files/node-classifier.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python3
-
-import yaml
-import sys
-import configparser
-
-# https://puppet.com/docs/puppet/7/nodes_external.html
-
-
-def main(args):
- if len(args) == 1:
- print('usage ./node-classifier <node-name>')
- return
-
- parser = configparser.ConfigParser()
- conf_file = '/etc/node-classifier.ini'
- if parser.read(conf_file) != [conf_file]:
- print(f'Configuration file missing, expected {conf_file}')
- return 1
-
- try:
- fmt = parser.get('common', 'node_fmt')
- if fmt != 'yaml':
- print(f'Unknown format {fmt}')
- return 1
- filename = parser.get('common', 'nodes')
- except configparser.NoSectionError as e:
- print(e)
- return 1
- except NoOptionError as e:
- print(e)
- return 1
-
- with open(filename) as f:
- data = yaml.load(f)
-
- nodename = sys.argv[1]
- instance = data.get(nodename)
- if not instance:
- instance = data.get('default')
- print(yaml.dump(instance))
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))