how to pass same variable value multiple times in a list

32 views
Skip to first unread message

Diyawary

unread,
Jun 9, 2020, 5:59:46 AM6/9/20
to Ansible Project
Hi Team,

I am using with_togather so i have two list one is mserver and other is domain, problem is i want to pass same mserver two times in the list ,but it is giving error and using only last defined value.

My requirement is for mserver list this can be same mserver or sometimes different mservers - name: Login to Checkpoint Management Server
      uri:
        url: "https://{{item.0}}/web_api/login"
        validate_certs: False
        method: POST
        body:
          user: "{{ mserver_username }}"
          password: "{{ mserver_password }}"
          domain: "{{item.1}}"
        body_format: json
      register: login
      failed_when: False
      when: item.0 != "" and item.1 != ""
mserver: {10,10,10,10, 10.10.10.10, 20.20.20.20}
doamin:{9.9.9.9,8.8.8.8,7.7.7.7}
 and i want execute like when mserver 10.10.10.10 then domain is 9.9.9.9
 and again mserver is 10.10.10.10 and domain is 8.8.8.8 so on.  and this two list mserver and domain I will get dynamically.
my playboolk
 tasks:
    - include_role:
        name: validateip
      when: object_type == "ip"
      with_together:
           - "{{ mserver }}"
           - "{{ domain }}"

 and in this role there are multiple tasks like login ,validation and logout I am performing 
for ex login playbook
 - name: Login to Checkpoint Management Server
      uri:
        url: "https://{{item.0}}/web_api/login"
        validate_certs: False
        method: POST
        body:
          user: "{{username }}"
          password: "{{ password }}"
          domain: "{{item.1}}"
        body_format: json
      register: login
      failed_when: False
      when: item.0 != "" and item.1 != ""

please help how to pass same values in list.

Diyawary

unread,
Jun 10, 2020, 2:54:41 AM6/10/20
to Ansible Project
Could  any one please help on it. is there any way how to use same items multiple times in a list .  Appreciate your help.

Brian Coca

unread,
Jun 10, 2020, 4:36:36 PM6/10/20
to Ansible Project
mserver and domain are not lists, lists use [ ] as delimiters not { }

--
----------
Brian Coca

Diyawary

unread,
Jun 12, 2020, 7:32:41 AM6/12/20
to Ansible Project
Thank You so much Brain. 
Reply all
Reply to author
Forward
0 new messages