Hi Team,

hoe i will get rid of dictionary or only grab first match in loop output 
with satisfying when condition.

==============================================================
files/isilon-allocation-KPHC.csv
===============================================================
Data Center,Environment,Business Purpose,Serial No.,Cluster Name,Dedicated 
region,IP Address
NDC,Production,KPHC,CF2ZJ203800133,cnnndcisip-hc01,SC,172.19.94.62
NDC,Production,KPHC,CF2ZJ204300024,,,172.19.94.63
NDC,Production,KPHC,CF2ZJ204300026,,,172.19.94.64
SSDC,Production,KPHC,JACNT205160062,massdcisip-hc01,MA,172.30.146.231
SSDC,Production,KPHC,JACNT210260055,,,172.30.146.232
SSDC,Production,KPHC,JACNT210260073,,,172.30.146.233
SSDC,Production,KPHC,JACNT210260083,,,172.30.146.234





===============================================================
default/main.yml
===============================================================
region: MA
primary_data_center: SSDC





===============================================================
task/main.yml
===============================================================

- name: "First Read isilon cluster csv file from mount point for login"
  community.general.read_csv:
    path: "{{ role_path }}/files/isilon-allocation-KPHC.csv"
  register: isilon_cluster_output


- name: "Print The inventry Full File in List format"
  ansible.builtin.debug:
    msg: "{{ isilon_cluster_output.list }}"


- name: "Get isilon host from isilon cluster file."
  ansible.builtin.set_fact:
    isilon_cluster_name_p: "{{ item['Cluster Name'] }}"
    isilon_ip_address_p: "{{ item['IP Address'] }}"
  when: (item['Data Center'] == primary_data_center) and (item['Dedicated 
region'] == region)
  loop: "{{ isilon_cluster_output.list }}"


- name: "Print The File System Name"
  ansible.builtin.debug:
    msg:
      - "{{ isilon_cluster_name_p }}"
      - "{{ isilon_ip_address_p }}"



==========================
Error
==========================



TASK [Print The File System Name] 
*********************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an 
undefined variable. The error was: 'isilon_cluster_name_p' is undefined. 
'isilon_cluster_name_p' is undefined\n\nThe error appears to be in 
'/home/ansiblecontroller/Desktop/TESTING/testing.yml': line 28, column 7, 
but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n\n    - name: \"Print The 
File System Name\"\n      ^ here\n"}



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dea04996-0bc1-4b61-b538-8494548185b1n%40googlegroups.com.

Reply via email to