Please dont suggest 'lookup' and default ansible modules.

On Thursday, June 6, 2019 at 1:58:52 AM UTC+5:30, Tanisha Mishra wrote:
>
> I am using csv python module for importing a csv file
> The csv is importing but unable to fetch the values properly.
> My main aim is the prompt that takes as server name needs to check from 
> the csv list whether it exists or not...
> I have to add 'when' condition also, but unable to separate HOST_NAME from 
> actual hostname(s)...
> I need help for 'when' condition and 'looping' of csv contents..
>
> -----------------------------------------------------------------------------------------------------------
> File: DBA_Total_server_list_modified.csv
>
> HOST_NAME
> zch89vsoedb106
> TX11FPSDB01V
> TX11FPSDB02V
> tx11fpsdb99v
>
> -----------------------------------------------------------------------------------------------------------
>
>
> -----------------------------------------------------------------------------------------------------------
> Playbook
> ---
> - name: "Play"
>   hosts: localhost
>   vars_prompt:
>     - name: server_name
>       prompt: "Enter a Server Name:"
>       private: no
>
>   tasks:
>
>     - name: Define values from csv
>       csv_facts:
>         src: "./DBA_Total_server_list_modified.csv"
>
>     - name: Display imported csv
>       debug:
>         var: hostvars[inventory_hostname].csv
>
>
> -----------------------------------------------------------------------------------------------------------
>
>
> -----------------------------------------------------------------------------------------------------------
> Output
> TASK [Display imported csv] 
> ***************************************************************
> ok: [localhost] => {
>     "hostvars[inventory_hostname].csv": [
>         {
>             "HOST_NAME": "zch89vsoedb106"
>         },
>         {
>             "HOST_NAME": "TX11FPSDB01V"
>         },
>         {
>             "HOST_NAME": "TX11FPSDB02V"
>         },
>         {
>             "HOST_NAME": "tx11fpsdb99v"
>         }
>     ]
> }
>
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f35ed89b-c484-4ed1-8750-4c32a980d45d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to