1
0
Fork 0
mirror of https://github.com/DO1JLR/ansible_linux_desktop_setup.git synced 2024-09-14 19:54:51 +02:00

update linting

This commit is contained in:
L3D 2022-06-18 13:45:34 +02:00
parent 293cff2649
commit c23aafa008

View file

@ -12,7 +12,7 @@ env_dict = {
'work':
['workstation.local'],
'private':
['dderpy.local', 'foo.bar']
['derpy.local', 'foo.bar']
}
def fqdn():
@ -24,6 +24,7 @@ def fqdn():
def env(domain):
"""
map a hostname to a space
or print empty list if no one matched and exit
"""
for key, values in env_dict.items():
if domain in values:
@ -39,6 +40,13 @@ def empty_host_list():
return json.loads('{"_meta": {"comment": "' + comment +
'", "hostvars": {}}, "instances": {"hosts": []}}')
def formated_host_group_list(host, group):
"""
build inventory and return it
"""
# pylint: disable=line-too-long
return json.loads('{"_meta": {"hostvars": {}},"' + str(group) + '": {"hosts": ["' + str(host) + '"]},"instances": {"children": ["' + str(group) + '"]}}')
def main():
"""
main funktion
@ -48,7 +56,10 @@ def main():
"""
host = fqdn()
group = env(host)
print(host + group)
print(json.dumps(formated_host_group_list(host, group), sort_keys=True, indent=2))
#{
# "_meta": {
# "hostvars": { }