I need to parse a ton of host names into a yaml file.
so far my code looks like this
hostname = input.txt
s = (f"{hostname}: \n"
f" hostname: {hostname}\n"
f" nodename: {hostname}\n"
f" username: rundeck\n"
f" tags: 'rundeck'\n")
print(s)
I have a massive txt file that looks something like
hostname1
hostname2
hokjdlaskdsfh4
abcdef8
that kind of thing,
I want to insert each line into the {hostname}
variable in the text.
And each line will result in a new "paragraph" Which I can then > into output.txt
forming a large file with all of the yaml code properly parsed. Each "output" in the output.yml file will look something like
hostname1:
hostname: hostname2
nodename: hostname2
username: rundeck
tags: 'rundeck'
abcdef:
hostname: abcdef
nodename: abcdef
username: rundeck
tags: 'rundeck'