My Ansible code works fine , if i call dictionary values from file . 

But requires guidance , how using the yaml file to pass as argument as INV 
file command line to execute playbook:

something like :

"ansible-playbook test.yml -e INV_FILE=latest123.yaml"

On Tuesday, September 3, 2019 at 4:31:37 AM UTC+5:30, Pawan Kumar wrote:
>
> Hi Dick,
>
> Thanks for replying . 
>
> Well said , i was working with Ansible to parse values from dictionary 
> file . 
>
> working with the following ansible playbook 
>
>
>
> ---
> - hosts: 127.0.0.1
>   connection: local
>   vars_files:
>     - latest123.yaml
>   tasks:
>
>     - name: Printing "releases" value from yaml file...
>       debug:
>         msg: "Name of the Product is {{ releases[item]['product_name'] }}  
> it's release candidate: {{ releases[item]['release_candidate'] }} & 
> version: {{ releases[item]['version'] }}"
>       with_items: "{{ releases.keys() }}"
>
>
>
>
> from the following latest123.yaml file 
>
>
> ---
> - releases:
>     gotcha:
>       file_name: gtp.tar
>       md5: 11f6987275613ca3ecf832ea59c1
>       product_name: gotcha
>       product_number: GTP 8881
>       release_candidate: rc19
>       version: 19.0.0
>     tp:
>       file_name: tpr.tar
>       md5: ebd7742ed8fff0472733c0cd8e
>       product_name: tp
>       product_number: TTP 8057
>       release_candidate: rc25
>       version: 25.0.0
>     device_name:
>       file_name: dna.tar
>       md5: e464e69a07123de075778aa9b7
>       product_name: device_name
>       product_number: DNP 6746
>       release_candidate: rc25
>       version: 25.0.0
>
>
>
>
> On Tuesday, September 3, 2019 at 4:06:16 AM UTC+5:30, Dick Visser wrote:
>>
>> Hi
>>
>> Kindly explain where ansible comes into play in this story?
>>
>> On Tue, 3 Sep 2019 at 00:18, Pawan Kumar <[email protected]> wrote:
>>
>>> Using Python script  to access values from yaml dictionary & print some 
>>> of the values as list . 
>>>
>>> For Example -  Parse the each key and extract the “product_name”, 
>>> “release_candidate” and “version“ & Print results as list
>>>
>>> The yaml file looks like 
>>>
>>>
>>>
>>> - releases:
>>>     - gotcha:
>>>         file_name: gtp.tar
>>>         md5: 11f6987275613ca3ecf832ea59c1
>>>         product_name: gotcha
>>>         product_number: GTP 8881
>>>         release_candidate: rc19
>>>         version: 19.0.0
>>>     - tp:
>>>         file_name: tpr.tar
>>>         md5: ebd7742ed8fff0472733c0cd8e
>>>         product_name: tp
>>>         product_number: TTP 8057
>>>         release_candidate: rc25
>>>         version: 25.0.0
>>>
>>> -- 
>>> 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/cdcb12c4-b6f6-4dbb-be42-b781e7d576d3%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/cdcb12c4-b6f6-4dbb-be42-b781e7d576d3%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> -- 
>> Sent from a mobile device - please excuse the brevity, spelling and 
>> punctuation.
>>
>

-- 
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/486f2e57-bed0-4a07-a841-81d090665633%40googlegroups.com.

Reply via email to