Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-04 Thread Pawan Kumar
Thanks @Zolvaring I tried your previous suggestion , ansible-playbook ansible_dictionary.yml -e INV_FILE=dictionaryFile.yaml But unable to print key values in dictonary format , For example - Each key is product. Parse the each key and extract the “product_name”, “release_candidate” and

Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-03 Thread Zolvaring
Hm okay I'm not sure that would work, but gojng back to your original example, have you tried passing the yaml file like this when you run the playbook? "--extra-vars=@your_yaml_file.yml" Reading I think that should work the same as running it "with_vars" -- You received this message because

Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-03 Thread Pawan Kumar
Thanks Zolvaring , Took input from the file & now output is coming in string format with following command --- Now , Requires formatting of the output to a list . "ansible-playbook test.yml -e INV_FILE=latest123.yaml" test.yml --- - hosts: 127.0.0.1 connection: local tasks: -

Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-02 Thread Zolvaring
I think what you want to do to use cli is specify the path as your var name just like your example, and then in your code when you invoke the variable, use the file lookup: - set_fact: your_fact: "{{ lookup('file', INV_VAR) }}" I'm not clear if you will need to do something beyond that for

Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-02 Thread Pawan Kumar
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

Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-02 Thread Pawan Kumar
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

Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-02 Thread Dick Visser
Hi Kindly explain where ansible comes into play in this story? On Tue, 3 Sep 2019 at 00:18, 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”, >

[ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-02 Thread Pawan Kumar
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: