0

I have a json as below :

    "instances": {
      "biometricsManagerInstance": {
        "appId": "biometrics-manager",
        "spawnType": "uniqueSiteWide"
       },
      "videoSensorInstance": {
        "appId": "video-sensor",
        "spawnType": "reuse"
      },
     "faceDetectionInstance":{  
        "appId": "face-detection",
        "spawnType": "reuse"
      },
     "faceMatchingInstance":{
       "appId": "face-matching",
       "spawnType": "new"
      },
      "faceAnnotatorInstance":{
        "appId": "face-annotator",
        "spawnType": "new"
       }
  }

I have a variable where the json is stored. Lets say : my_json_contents I want to create a dictionary from this data which has values like :

    {"biometrics-manager":"biometricsManagerInstance","video-sensor":"videoSensorInstance","face-detection":"faceDetectionInstance",..}

I want to achieve it using ansible. Help is appreciated.TIA.

1 Answer 1

1

Here you are:

- set_fact:
    instances_modified: "{{ instances_modified | default({}) | combine({item.1.appId: item.0}) }}"
  loop: "{{ instances | dictsort }}"
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for providing the response!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.