How to loop over this local_fact in Ansible?

Its not clear to me exactly what you want the result to be after your set_fact processing but I suggest you take a look at json_query plugin as you might be able to use this to just pick out the bits of the result that you need. See http://docs.ansible.com/ansible/latest/playbooks_filters.html#json-query-filter

One of the nice things about json_query is you can use the JMESPath examples page here: http://jmespath.org/examples.html to try out your queries (just paste your json into an input box and tinker with the query until you get results you need.

Hope this helps,

Jon