Question:I have to update a config file with server IPs from a cluster. The cluster contains minimum 2 servers, however, the maximum number of servers in the cluster is unknown. I want to collect the IPs as a delimited list IP1|IP2|IPn and split them into separate variables. The below snippet is working fine with two variables.
- How can I split a collected string into separate variables?
- How can I generalize the above insert to n number of IPs?
Answer:With a list of comma delimited IP addresses (YAML) such as:
splitmethod in your Jinja2 templating to obtain a list:
joinfilter takes 1 argument, which is the character to delimit each item in the list in the output of the template.
If you have better answer, please add a comment about this, thank you!