Closed vinugupta80 closed 2 years ago
I think problem is, that mapping set LUN access to match EXACLY list provided by 'hosts' list. So if you are trying to ADD new host in second loop iteration, it will overwrite access host from first iteration. If you want to map more then 1 host, don't use loops. Prepare variable with all hosts in form expected by module, and run it once, setting multiple hosts in one go, ie:
- name: Final host list in form expected by module
set_fact:
hosts_list: "{{ hosts_list|default([]) + [ { 'host_name': item } ] }}"
loop: "{{ list_of_host_names }}"
- name: Map volume {{ lun_name }} to Hosts
dellemc_unity_volume:
<<: *collection_creds
vol_name: "{{ lun_name }}"
hosts: "{{ hosts_list }}"
mapping_state: "mapped"
state: "present"
Closed by #19
I am facing issue while using Ansible loop for mapping of Unity LUNs to multiple Host.
Attached the file having 3 scenarios.
In scenario 3 : I am using a Static value for Host_name and HLU inside Hosts: in playbook and everything is working fine. But issue is if we have more hosts in place we have to modify the playbook every time.
In Scenario 1 : Using Loop and Host_name & HLU inside Hosts: In this case my play failed with error msg: "Invalid input parameter for host_name" In Scenario 2: Task Run Successfully but LUN allocated to One Host , not respecting Idempotent feature. Task Run twice and when it run 2nd time it removes the host added during Task 1
System Information (please complete the following information):
Additional context Ansible_loop.xlsx
Add any other context about the problem here. Ansible_loop.xlsx