print "#{0}".format(conf_line) print """ ## [CUSTOM] ## # # This is a hash of custom value configs to append to conf file # Format: (json) # { # 'section': { # 'name': 'value' # } # } """ print "{0}_{1}: {2}".format(prefix, namespace, '{}') if __name__ == '__main__': fpath = sys.argv[1] namespace = sys.argv[2] if len(sys.argv) >= 3 else '' prefix = sys.argv[3] if len(sys.argv) >= 4 else '' desc = sys.argv[4] if len(sys.argv) >= 5 else '' parser = OSConfigParser() with open(fpath) as f: lines = [line.strip() for line in f.readlines()] parser.parse(lines) show_header(fpath, namespace, prefix, desc) print_ansible_conf(parser, prefix=prefix, namespace=namespace)
# custom section configs print """ # # Custom section configs # {%% for section, keypair in %s | dictsort %%} [{{ section }}] {%% if keypair is not string %%} {%% for name, value in keypair | dictsort %%} {{ name }}={{ value }} {%% endfor %%} {%% endif %%} {%% endfor %%}""" % "{0}_{1}".format(prefix, namespace) if __name__ == '__main__': fpath = sys.argv[1] namespace = sys.argv[2] if len(sys.argv) >= 3 else '' prefix = sys.argv[3] if len(sys.argv) >= 4 else '' desc = sys.argv[4] if len(sys.argv) >= 5 else '' parser = OSConfigParser() with open(fpath) as f: lines = [line.strip() for line in f.readlines()] parser.parse(lines) show_header(fpath, namespace, prefix, desc, yaml=False) print_ini_jinja(parser, prefix=prefix, namespace=namespace)