So I have 2 json array filesone with some simple data (could be any number of servers):
[ {"playbook": "simplerun.yml","server": "abc","status": "success" }, {"playbook": "simplerun.yml","server": "def","status": "success" } etc ]
and a master file (hundreds of thousands of servers) with enhanced data about the server (but is called Name)
[ {"name": "abc","fqdn": "abc.com","env": "UAT","ip_address": "0.0.0.0","owner": "John Doe" }, {"name": "def","fqdn": "def.com","env": "PROD","ip_address": "0.0.0.1","owner": "Jane Doe" } etc ]
what I would like to have is
[ {"playbook": "simplerun.yml","server": "abc","status": "success","fqdn": "abc.com","env": "UAT","ip_address": "0.0.0.0","owner": "John Doe" }, {"playbook": "simplerun.yml","server": "def","status": "success","fqdn": "def.com","env": "PROD","ip_address": "0.0.0.1","owner": "Jane Doe" } ]
I know it must be simple, but
Any help is greatly appreciated.
I have tried combine
- name: set fact set_fact: key1: "server" key2: "name" - name: join data set_fact: joined_data: >- {{ jsonfile1 | map ('combine', jsonfile2 |selectattr (key2,'eq', item[key1]|list|first|default ({})) }} loop: "{{ jsonfile1 }}" loop_control: loop_var: item
however that only produced the same values for all the entries in the simple data.