Matthew Mosesohn | ae26ec8 | 2017-05-19 18:47:33 +0300 | [diff] [blame] | 1 | import salt.modules.cmdmod |
2 | import re | ||||
3 | from salt.exceptions import CommandExecutionError | ||||
4 | |||||
5 | |||||
6 | def main(): | ||||
7 | grains = {} | ||||
8 | try: | ||||
9 | raw_k8s_ver = salt.modules.cmdmod._run_quiet('hyperkube --version') | ||||
10 | ver = re.search('(v[0-9.-]+)', raw_k8s_ver) | ||||
11 | if ver: | ||||
12 | grains['kubernetes_version'] = ver.group(1) | ||||
13 | except CommandExecutionError: | ||||
14 | pass | ||||
15 | return grains |