From 22503e7e11b6e28c7748ba965cf114e7639824ab Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 29 Nov 2018 15:21:37 -0500 Subject: [PATCH] Inject blank lines in ansible hosts file This looks a bit more like a natural hosts file. --- confluent_client/bin/confluent2ansible | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/confluent_client/bin/confluent2ansible b/confluent_client/bin/confluent2ansible index 20cbd5e6..2f16dd84 100644 --- a/confluent_client/bin/confluent2ansible +++ b/confluent_client/bin/confluent2ansible @@ -48,19 +48,24 @@ def main(): databynode[node].update(res['databynode'][node]) nodesbygroup = {} with open(options.output, 'w') as importfile: + needempty = False for node in sortutil.natural_sort(databynode): data = databynode[node] if not data.get('groups', []): importfile.write(node + '\n') + needempty = True for g in data.get('groups', []): if g not in nodesbygroup: nodesbygroup[g] = set([node]) else: nodesbygroup[g].add(node) + if needempty: + importfile.write('\n') for group in sortutil.natural_sort(nodesbygroup): importfile.write('[{0}]\n'.format(group)) for node in sortutil.natural_sort(nodesbygroup[group]): importfile.write('{0}\n'.format(node)) + importfile.write('\n') if __name__ == '__main__':