I merged two lists from an Ansible inventory:
set_fact:
fact1: "{{ groups['group1'] + groups[group2']|list }}
The output is:
fact1:
- server01
- server02
- server03
With the above results, I need to append https://
to the front, and a port number to the back of each element.
Then I need to convert it to a comma delimited list for a server config.
In this example I want: https://server01:8000,https://server02:8000,https://server03:8000
.
I tried using a join:
set_fact:
fact2: "{{ fact1|join(':8000,') }}"
which partly worked but it left the last server without a port.
How can I achieve my goal?
(.*)
will match the whole string and an empty string at the end, which means it will make two replacements: docs.ansible.com/ansible/latest/user_guide/…. We should use^(.*)$
instead. – Fletafletch