How to split received multi valued variables from snow and run on a single template

Hi Team,

currently in my playbook I am using single valued variables hostname and domain,now I am getting variables mserver_hostname and domain as multiple values from snow.
like mserver_hostname: 1.1.1.1, 2.2.2.2
doamin: 3.3.3.3, 4.4.4.4
how I can before passing split this and make two different set of variables in my playbook and use on a single template
I mean like
mserver_hostname: 10.10.10.10
doamin: 10.10.10.30
and 2nd set like
mserver_hostname: 10.10.20.20
doamin: 10.10.10.40

My playbooks are very complex and various roles are there and I already tried loops(with_togather) but that is not appropriate for my playbook and tasks are failing

My main objective is how to create create different set of variables from the received multi valued variables and use them into my playbook. on a single template
for ex- my login playbook -

  • name: Login to CP Server
    uri:
    url: “https://{{hostname}}/web_api/login”
    validate_certs: False
    method: POST
    body:
    user: “{{ mserver_username }}”
    password: “{{ mserver_password }}”
    domain: “{{domain}}”
    body_format: json
    register: login
    failed_when: False
    when: item.0 != “” and item.1 != “”
    with_together:

  • “{{ hostname }}”

  • “{{ domain }}”

  • debug:
    msg: " |~ +Failed+ Login failed to management server [{{ hostname }}] CODE:{{login.status}} ERROR: {{login.json.code}} - {{login.json.message}} |~"
    when: login.status != 200

  • debug:
    msg: “Login successful to management server [{{ hostname }}]”
    when: login.status == 200