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 “version“



*ansible_dictionary.yml*


---
- hosts: 127.0.0.1
  connection: local

  tasks:


    - name: Print
      set_fact:
        your_fact: "{{ lookup('file', INV_FILE) }}"
        stdout_callback: yaml
    - name: Output Formatting
      set_fact:
        filtered_data: "{{ your_fact.split('\n') }}"
    - name: Testing
      debug:
        msg: "{{ filtered_data }}"


*With Following Output......*


TASK [Output Formatting] 
********************************************************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [Testing] 
******************************************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": [
        "- 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 Wednesday, September 4, 2019 at 10:45:45 AM UTC+5:30, Zolvaring wrote:
>
> 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 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/fd9183de-5a70-48f1-94ff-063fb42af53f%40googlegroups.com.

Reply via email to