Hi guys

I need some help with looping my local_facts as I am struggling to match 
the key/value

Example of my facts file:

{
  "env": [
    "ppe",
    "trn"
  ],
  "websphere_dir": "/WebSphere8",
  "tech": "was8",
  "profiles": {
    "epn-was8-dmgr-ppe": {
      "env": "ppe"
    },
    "epn-was8-dmgr-trn": {
      "env": "trn"
    },
    "epn-was8-node-ppe-01": {
      "env": "ppe"
    },
    "epn-was8-node-trn-01": {
      "env": "trn"
    }
  }
}



Code in playbook:

    - set_fact:
        profiles_dicts: |
          {% set res = [] -%}
          {% for key in ansible_local.was.profiles.keys() -%}
            {% for value in ansible_local.was.profiles[key] -%}
              {% set ignored = res.extend([{'Server': key, 'ENV':value}]) 
-%}
           {%- endfor %}
          {%- endfor %}
          {{ res }}


Output:

{
    "profiles_dicts": [
        {
            "ENV": "env",
            "Server": "epn-was8-dmgr-trn"
        },
        {
            "ENV": "env",
            "Server": "epn-was8-node-trn-01"
        },
        {
            "ENV": "env",
            "Server": "epn-was8-node-ppe-01"
        },
        {
            "ENV": "env",
            "Server": "epn-was8-dmgr-ppe"
        }


Is it possible to change my loop in order for my output to be ENV to match 
PPE or TRN and not env?

I am not sure how to achieve this


-- 
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/2a13f3ce-7735-4425-9254-620a0b1c0355%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to