I have multiple json files look like this: 
temp/file-a.json:
{
     “x”: 5”,
      “y”: “name1”,
}

tmp/file-b.jsob:
{
     “x”: “10”,
      “y”: “name2”,
}

tmp/file-c.json:
{
    “x”: “7”,
    “y”: “name3”,
}

....... and more

All json files are on the same server where I place my playbook. My goal is to 
access variable x from each json file. If x<6, I will copy json file to another 
remote hostA. I can use the following playbook to achieve my goal for single 
json file:

—-
- hosts: hostA
  tasks:
     - include_vars:
          file: tmp/file-a.json
          name: my_var

     - name: copy files to hostA
           copy:
               src=tmp/file-a.json
               dest=/hostA/tmp/
           when: “{{ my_var.x|int }} “< 6

How do I do this for all json files under tmp/ directory?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b50b2049-2372-4ae3-9f47-ee04746fab32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to