Hey Pawan, I got the laptop out and tried: ansible-playbook testplay.yml -i localhost, -e "@testvars.yml"
and got: ERROR! Invalid extra vars data supplied. '@testvars.yml' could not be made into a dictionary After digging, I found: https://github.com/ansible/ansible/issues/38415 https://github.com/ansible/ansible/pull/31433 The above issues (Recent as of Dec 2018) point out that YAML was never accepted as CLI args, though at one point the documentation erroneously claimed it was. What I did was this: --- - hosts: 127.0.0.1 connection: local vars_files: - "{{ TEST }}" tasks: - name: Testing debug: msg: "{{ releases }}" --- - 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 And then ran: ansible-playbook testplay.yml -i localhost, -e "TEST=testvars.yml" And got: TASK [Gathering Facts] ************************************************************************************************************************************************************** ok: [localhost] TASK [Testing] ********************************************************************************************************************************************************************** ok: [localhost] => { "msg": { "device_name": { "file_name": "dna.tar", "md5": "e464e69a07123de075778aa9b7", "product_name": "device_name", "product_number": "DNP 6746", "release_candidate": "rc25", "version": "25.0.0" }, "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" } } } It looks to me like if you want to dynamically supply the vars file as YAML on cli, that is your best bet. Use 'vars_files' with a dynamic var and declare that var on the cli On Monday, September 2, 2019 at 3:18:42 PM UTC-7, Pawan Kumar 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/9855ec15-da66-44dc-91d8-f07201533089%40googlegroups.com.
