Parsing and creating new variables from inventory hostgroup

I have a hostgroup that have 4 hosts in it:

Example:

[ {
“shcdeployer”,
“shcnode1”,
“shcnode3”,
“shcnode3”
} ]

I need to get two things actually

  1. A shcnode* node picked out of the list, does not matter
  2. A string list of the nodes like: https://shcnode1:8089,https://shcnode2:8089,https//shcnode3:8089

There has to to be some easy trick that I am missing. I am also looking into also creating a python script to parse it as well.

Thoughts?

for the first, the random_choice filter seems to be what you want:

anynode: "{{ groups['shc_hosts']|random_choice }}"

for the 2nd something like:

urllist: "{{ groups['shc_hosts']|map('regex_replace', '^(.*)$',
'https://'')|list|join(':8089,')}}:8089"

This does not seem to work:

The filter is called random, random_choice is a lookup plugin.