Repository: ansible/ansible

Issue:
'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'configuration'
<!---
Verify first that your issue/request is not already reported on GitHub.
Also test if the latest release, and master branch are affected too.
-->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the module/plugin/task/feature -->
junos_facts

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/joe/ansible/library']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]
```

##### CONFIGURATION
<!---
If using Ansible 2.4 or above, paste the results of "ansible-config dump --only-changed"

Otherwise, mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).

-->
DEFAULT_CALLBACK_PLUGIN_PATH(/etc/ansible/ansible.cfg) = [u'/home/joe/ansible/playbooks/callback_plugins']
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = [u'/home/joe/ansible/hosts']
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /home/joe/ansible/ansible.log
DEFAULT_MODULE_PATH(/etc/ansible/ansible.cfg) = [u'/home/joe/ansible/library']
HOST_KEY_CHECKING(/etc/ansible/ansible.cfg) = False
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30


##### OS / ENVIRONMENT
<!---
Mention the OS you are running Ansible from, and the OS you are
managing, or say "N/A" for anything that is not platform-specific.
Also mention the specific version of what you are trying to control,
e.g. if this is a network bug the version of firmware on the network device.
-->
Ubuntu 16.04

##### SUMMARY
<!--- Explain the problem briefly -->
When navigated through output of junos_facts config, which is json output, as soon as I navigate to ansible_facts.ansible_net_config.configuration I get the error,
'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'configuration'
I have seen similar errors with ansible.vars.unsafe_proxy but nothing matching my error.

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem, using a minimal test-case.
For new features, show how the feature would be used.
-->
run the playbook I have attached on Juniper SRX and error will appear.  I have tested going into configuration as well as configuration[0].
<!--- Paste example playbooks or commands between quotes below -->
```yaml
---
- name: get junos config info
  junos_facts:
    provider: "{{ provider }}"
    gather_subset: config
    config_format: json
  register: srx_info
  
- name: print information
  debug:
    msg: "{{ srx_info.ansible_facts.ansible_net_config.configuration }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
I expect to navigate to configuration, which is a list.  I want to enter the list and navigate through configuration information to get results and do stuff with that information.
##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
TASK [junos_info : get junos interface info] ******************************************************************************************************************************************************************
task path: /home/joe/ansible/playbooks/roles/junos_info/tasks/main.yml:2
<10.1.170.9> using connection plugin netconf
<10.1.170.9> socket_path: /home/joe/.ansible/pc/53f14f0353
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/network/junos/junos_facts.py
<10.1.170.9> ESTABLISH LOCAL CONNECTION FOR USER: joe
<10.1.170.9> EXEC /bin/sh -c 'echo ~ && sleep 0'
<10.1.170.9> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117 `" && echo ansible-tmp-1507575562.88-121003161397117="` echo /home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117 `" ) && sleep 0'
<10.1.170.9> PUT /tmp/tmp73x6eK TO /home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117/junos_facts.py
<10.1.170.9> EXEC /bin/sh -c 'chmod u+x /home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117/ /home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117/junos_facts.py && sleep 0'
<10.1.170.9> EXEC /bin/sh -c '/usr/bin/python /home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117/junos_facts.py; rm -rf "/home/joe/.ansible/tmp/ansible-tmp-1507575562.88-121003161397117/" > /dev/null 2>&1 && sleep 0'
ok: [10.1.170.9] => {
    "ansible_facts": {
        "ansible_net_config": "{\n    \"configuration\" : [\n    {\n        \"attributes\" : {\"xmlns\" : \"http://xml.juniper.net/xnm/1.1/xnm\", \n                        \"junos:changed-seconds\" : \"1507556601\", \n                        \"junos:changed-localtime\" : \"2017-10-09 13:43:21 UTC\"\n                       }, \n        \"version\" : [\n        {\n            \"data\" : \"15.1X49-D80.4\"\n        }\n        ], \n        \"system\" : [\n        {\n            \"host-name\" : [\n            {\n                \"data\" : \"Client-A-Site-1\"\n            }\n            ], \n            \"root-authentication\" : [\n            {\n                \"encrypted-password\" : [\n                {\n                    \"data\" : \"$5$Ylowgyag$iztLzkvH93tXNa6PhXm7ZNOj74GDbSsda.kqcgAIy00\"\n                }\n                ]\n            }\n            ], \n            \"login\" : [\n            {\n                \"user\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"username\"\n                    }, \n                    \"uid\" : [\n                    {\n                        \"data\" : \"2000\"\n                    }\n                    ], \n                    \"class\" : [\n                    {\n                        \"data\" : \"super-user\"\n                    }\n                    ], \n                    \"authentication\" : [\n                    {\n                        \"encrypted-password\" : [\n                        {\n                            \"data\" : \"$5$jih26QX5$fA1AqKy0q8u5Bba/ICkzg3BFCBNBnvVkSlXs2f5Z9w6\"\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"services\" : [\n            {\n                \"ssh\" : [\n                {\n                }\n                ], \n                \"telnet\" : [\n                {\n                }\n                ], \n                \"netconf\" : [\n                {\n                    \"ssh\" : [\n                    {\n                    }\n                    ], \n                    \"traceoptions\" : [\n                    {\n                        \"flag\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"all\"\n                            }\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ], \n                \"rest\" : [\n                {\n                    \"http\" : [\n                    {\n                        \"addresses\" : [\n                        {\n                            \"data\" : \"10.1.170.9\"\n                        }\n                        ]\n                    }\n                    ], \n                    \"traceoptions\" : [\n                    {\n                        \"flag\" : [\n                        {\n                            \"data\" : \"all\"\n                        }\n                        ]\n                    }\n                    ], \n                    \"enable-explorer\" : [\n                    {\n                        \"data\" : null\n                    }\n                    ]\n                }\n                ], \n                \"webapi\" : [\n                {\n                    \"user\" : [\n                    {\n                        \"user-name\" : [\n                        {\n                            \"data\" : \"username\"\n                        }\n                        ], \n                        \"password\" : [\n                        {\n                            \"data\" : \"$9$rJEK87ws4GjqoaFn9C1IlKMW7VY24\"\n                        }\n                        ]\n                    }\n                    ], \n                    \"http\" : [\n                    {\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"syslog\" : [\n            {\n                \"host\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"10.77.71.17\"\n                    }, \n                    \"contents\" : [\n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"any\"\n                        }, \n                        \"any\" : [\n                        {\n                            \"data\" : null\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ], \n                \"file\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"Denied-Traffic\"\n                    }, \n                    \"contents\" : [\n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"any\"\n                        }, \n                        \"any\" : [\n                        {\n                            \"data\" : null\n                        }\n                        ]\n                    }\n                    ], \n                    \"match\" : [\n                    {\n                        \"data\" : \"RT_FLOW_SESSION_DENY\"\n                    }\n                    ]\n                }\n                ], \n                \"source-address\" : [\n                {\n                    \"data\" : \"10.85.64.21\"\n                }\n                ]\n            }\n            ]\n        }\n        ], \n        \"security\" : [\n        {\n            \"ike\" : [\n            {\n                \"proposal\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"IKE-PROPOSAL\"\n                    }, \n                    \"authentication-method\" : [\n                    {\n                        \"data\" : \"pre-shared-keys\"\n                    }\n                    ], \n                    \"dh-group\" : [\n                    {\n                        \"data\" : \"group5\"\n                    }\n                    ], \n                    \"authentication-algorithm\" : [\n                    {\n                        \"data\" : \"sha1\"\n                    }\n                    ], \n                    \"encryption-algorithm\" : [\n                    {\n                        \"data\" : \"aes-256-cbc\"\n                    }\n                    ], \n                    \"lifetime-seconds\" : [\n                    {\n                        \"data\" : \"28800\"\n                    }\n                    ]\n                }\n                ], \n                \"policy\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"IKE-POLICY\"\n                    }, \n                    \"mode\" : [\n                    {\n                        \"data\" : \"main\"\n                    }\n                    ], \n                    \"proposals\" : [\n                    {\n                        \"data\" : \"IKE-PROPOSAL\"\n                    }\n                    ], \n                    \"pre-shared-key\" : [\n                    {\n                        \"ascii-text\" : [\n                        {\n                            \"data\" : \"$9$GtUkmPfQn9p5QrvMWx7jHq.PQ\"\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ], \n                \"gateway\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"HQ-1\"\n                    }, \n                    \"ike-policy\" : [\n                    {\n                        \"data\" : \"IKE-POLICY\"\n                    }\n                    ], \n                    \"address\" : [\n                    {\n                        \"data\" : \"10.1.170.20\"\n                    }\n                    ], \n                    \"local-identity\" : [\n                    {\n                        \"inet\" : [\n                        {\n                            \"identity-ipv4\" : [\n                            {\n                                \"data\" : \"10.1.170.9\"\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ], \n                    \"external-interface\" : [\n                    {\n                        \"data\" : \"ge-0/0/0.0\"\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"ipsec\" : [\n            {\n                \"proposal\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"IPSEC-PROPOSAL\"\n                    }, \n                    \"protocol\" : [\n                    {\n                        \"data\" : \"esp\"\n                    }\n                    ], \n                    \"authentication-algorithm\" : [\n                    {\n                        \"data\" : \"hmac-sha1-96\"\n                    }\n                    ], \n                    \"encryption-algorithm\" : [\n                    {\n                        \"data\" : \"aes-256-cbc\"\n                    }\n                    ], \n                    \"lifetime-seconds\" : [\n                    {\n                        \"data\" : \"3600\"\n                    }\n                    ]\n                }\n                ], \n                \"policy\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"IPSEC-POLICY\"\n                    }, \n                    \"proposals\" : [\n                    {\n                        \"data\" : \"IPSEC-PROPOSAL\"\n                    }\n                    ]\n                }\n                ], \n                \"vpn\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"HQ-1\"\n                    }, \n                    \"bind-interface\" : [\n                    {\n                        \"data\" : \"st0.0\"\n                    }\n                    ], \n                    \"ike\" : [\n                    {\n                        \"gateway\" : [\n                        {\n                            \"data\" : \"HQ-1\"\n                        }\n                        ], \n                        \"proxy-identity\" : [\n                        {\n                            \"remote\" : [\n                            {\n                                \"data\" : \"10.85.50.2/32\"\n                            }\n                            ], \n                            \"service\" : [\n                            {\n                                \"data\" : \"junos-gre\"\n                            }\n                            ]\n                        }\n                        ], \n                        \"ipsec-policy\" : [\n                        {\n                            \"data\" : \"IPSEC-POLICY\"\n                        }\n                        ]\n                    }\n                    ], \n                    \"establish-tunnels\" : [\n                    {\n                        \"data\" : \"immediately\"\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"flow\" : [\n            {\n                \"tcp-mss\" : [\n                {\n                    \"ipsec-vpn\" : [\n                    {\n                        \"mss\" : [\n                        {\n                            \"data\" : \"1350\"\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"policies\" : [\n            {\n                \"policy\" : [\n                {\n                    \"from-zone-name\" :\n                    {\n                        \"data\" : \"private\"\n                    }, \n                    \"to-zone-name\" :\n                    {\n                        \"data\" : \"private\"\n                    }, \n                    \"policy\" : [\n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"permit-all\"\n                        }, \n                        \"match\" : [\n                        {\n                            \"source-address\" : [\n                            {\n                                \"data\" : \"any\"\n                            }\n                            ], \n                            \"destination-address\" : [\n                            {\n                                \"data\" : \"any\"\n                            }\n                            ], \n                            \"application\" : [\n                            {\n                                \"data\" : \"any\"\n                            }\n                            ]\n                        }\n                        ], \n                        \"then\" : [\n                        {\n                            \"permit\" : [\n                            {\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"zones\" : [\n            {\n                \"security-zone\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"public\"\n                    }, \n                    \"host-inbound-traffic\" : [\n                    {\n                        \"system-services\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"all\"\n                            }\n                        }\n                        ], \n                        \"protocols\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"all\"\n                            }\n                        }\n                        ]\n                    }\n                    ], \n                    \"interfaces\" : [\n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"ge-0/0/0.0\"\n                        }\n                    }\n                    ]\n                }, \n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"private\"\n                    }, \n                    \"host-inbound-traffic\" : [\n                    {\n                        \"system-services\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"all\"\n                            }\n                        }\n                        ], \n                        \"protocols\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"all\"\n                            }\n                        }\n                        ]\n                    }\n                    ], \n                    \"interfaces\" : [\n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"st0.0\"\n                        }\n                    }, \n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"gr-0/0/0.0\"\n                        }\n                    }, \n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"ge-0/0/1.0\"\n                        }\n                    }\n                    ]\n                }\n                ]\n            }\n            ]\n        }\n        ], \n        \"interfaces\" : [\n        {\n            \"interface\" : [\n            {\n                \"name\" :\n                {\n                    \"data\" : \"ge-0/0/0\"\n                }, \n                \"unit\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"0\"\n                    }, \n                    \"family\" : [\n                    {\n                        \"inet\" : [\n                        {\n                            \"address\" : [\n                            {\n                                \"name\" :\n                                {\n                                    \"data\" : \"10.1.170.9/22\"\n                                }\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }, \n            {\n                \"name\" :\n                {\n                    \"data\" : \"gr-0/0/0\"\n                }, \n                \"unit\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"0\"\n                    }, \n                    \"clear-dont-fragment-bit\" : [\n                    {\n                        \"data\" : null\n                    }\n                    ], \n                    \"tunnel\" : [\n                    {\n                        \"source\" : [\n                        {\n                            \"data\" : \"10.85.64.21\"\n                        }\n                        ], \n                        \"destination\" : [\n                        {\n                            \"data\" : \"10.85.50.2\"\n                        }\n                        ], \n                        \"allow-fragmentation\" : [\n                        {\n                            \"data\" : null\n                        }\n                        ]\n                    }\n                    ], \n                    \"family\" : [\n                    {\n                        \"inet\" : [\n                        {\n                            \"mtu\" : [\n                            {\n                                \"data\" : \"1400\"\n                            }\n                            ], \n                            \"address\" : [\n                            {\n                                \"name\" :\n                                {\n                                    \"data\" : \"172.23.1.6/30\"\n                                }\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }, \n            {\n                \"name\" :\n                {\n                    \"data\" : \"ge-0/0/1\"\n                }, \n                \"vlan-tagging\" : [\n                {\n                    \"data\" : null\n                }\n                ], \n                \"unit\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"0\"\n                    }, \n                    \"vlan-id\" : [\n                    {\n                        \"data\" : \"1\"\n                    }\n                    ], \n                    \"family\" : [\n                    {\n                        \"inet\" : [\n                        {\n                            \"address\" : [\n                            {\n                                \"name\" :\n                                {\n                                    \"data\" : \"192.168.3.1/24\"\n                                }\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }, \n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"201\"\n                    }, \n                    \"vlan-id\" : [\n                    {\n                        \"data\" : \"210\"\n                    }\n                    ], \n                    \"family\" : [\n                    {\n                        \"inet\" : [\n                        {\n                            \"address\" : [\n                            {\n                                \"name\" :\n                                {\n                                    \"data\" : \"10.12.1.254/24\"\n                                }\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }, \n            {\n                \"name\" :\n                {\n                    \"data\" : \"lo0\"\n                }, \n                \"unit\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"10\"\n                    }, \n                    \"family\" : [\n                    {\n                        \"inet\" : [\n                        {\n                            \"address\" : [\n                            {\n                                \"name\" :\n                                {\n                                    \"data\" : \"10.85.64.21/32\"\n                                }\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }, \n            {\n                \"name\" :\n                {\n                    \"data\" : \"st0\"\n                }, \n                \"unit\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"0\"\n                    }, \n                    \"family\" : [\n                    {\n                        \"inet\" : [\n                        {\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }\n            ]\n        }\n        ], \n        \"routing-options\" : [\n        {\n            \"static\" : [\n            {\n                \"route\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"0.0.0.0/0\"\n                    }, \n                    \"next-hop\" : [\n                    {\n                        \"data\" : \"10.1.170.1\"\n                    }\n                    ]\n                }, \n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"10.85.50.2/32\"\n                    }, \n                    \"next-hop\" : [\n                    {\n                        \"data\" : \"st0.0\"\n                    }\n                    ]\n                }\n                ]\n            }\n            ], \n            \"autonomous-system\" : [\n            {\n                \"as-number\" : [\n                {\n                    \"data\" : \"65002\"\n                }\n                ]\n            }\n            ]\n        }\n        ], \n        \"protocols\" : [\n        {\n            \"bgp\" : [\n            {\n                \"group\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"external-peers\"\n                    }, \n                    \"type\" : [\n                    {\n                        \"data\" : \"external\"\n                    }\n                    ], \n                    \"export\" : [\n                    {\n                        \"data\" : \"send-filtered-direct\"\n                    }\n                    ], \n                    \"peer-as\" : [\n                    {\n                        \"data\" : \"65000\"\n                    }\n                    ], \n                    \"neighbor\" : [\n                    {\n                        \"name\" :\n                        {\n                            \"data\" : \"172.23.1.5\"\n                        }\n                    }\n                    ]\n                }\n                ]\n            }\n            ]\n        }\n        ], \n        \"policy-options\" : [\n        {\n            \"prefix-list\" : [\n            {\n                \"name\" :\n                {\n                    \"data\" : \"bgp-adv\"\n                }, \n                \"prefix-list-item\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"192.168.3.0/24\"\n                    }\n                }\n                ]\n            }\n            ], \n            \"policy-statement\" : [\n            {\n                \"name\" :\n                {\n                    \"data\" : \"send-filtered-direct\"\n                }, \n                \"term\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"10\"\n                    }, \n                    \"from\" : [\n                    {\n                        \"protocol\" : [\n                        {\n                            \"data\" : \"direct\"\n                        }\n                        ], \n                        \"prefix-list\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"bgp-adv\"\n                            }\n                        }\n                        ]\n                    }\n                    ], \n                    \"then\" : [\n                    {\n                        \"accept\" : [\n                        {\n                            \"data\" : null\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }\n            ]\n        }\n        ], \n        \"routing-instances\" : [\n        {\n            \"instance\" : [\n            {\n                \"name\" :\n                {\n                    \"data\" : \"201\"\n                }, \n                \"interface\" : [\n                {\n                    \"name\" :\n                    {\n                        \"data\" : \"ge-0/0/1.201\"\n                    }\n                }\n                ], \n                \"routing-options\" : [\n                {\n                    \"static\" : [\n                    {\n                        \"route\" : [\n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"0.0.0.0/0\"\n                            }, \n                            \"next-hop\" : [\n                            {\n                                \"data\" : \"10.12.1.55\"\n                            }\n                            ]\n                        }, \n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"192.168.108.1/32\"\n                            }, \n                            \"next-hop\" : [\n                            {\n                                \"data\" : \"10.12.1.253\"\n                            }\n                            ]\n                        }, \n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"10.88.108.0/24\"\n                            }, \n                            \"next-hop\" : [\n                            {\n                                \"data\" : \"10.12.1.253\"\n                            }\n                            ]\n                        }, \n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"172.1.108.1/32\"\n                            }, \n                            \"next-hop\" : [\n                            {\n                                \"data\" : \"10.12.1.253\"\n                            }\n                            ]\n                        }, \n                        {\n                            \"name\" :\n                            {\n                                \"data\" : \"10.99.108.0/24\"\n                            }, \n                            \"next-hop\" : [\n                            {\n                                \"data\" : \"10.12.1.253\"\n                            }\n                            ]\n                        }\n                        ]\n                    }\n                    ]\n                }\n                ]\n            }\n            ]\n        }\n        ]\n    }\n    ]\n}",
        "ansible_net_gather_subset": [
            "default",
            "config"
        ],
        "ansible_net_hostname": "Client-A-Site-1",
        "ansible_net_model": "vsrx",
        "ansible_net_serialnum": "BC5596152867",
        "ansible_net_version": "15.1X49-D80.4"
    },
    "changed": false,
    "failed": false,
    "invocation": {
        "module_args": {
            "config_format": "json",
            "gather_subset": [
                "config"
            ],
            "host": null,
            "password": null,
            "port": null,
            "provider": {
                "host": "10.1.170.9",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": null,
                "username": "username"
            },
            "ssh_keyfile": null,
            "timeout": null,
            "transport": null,
            "username": null
        }
    }
}

TASK [junos_info : print information] *************************************************************************************************************************************************************************
task path: /home/joe/ansible/playbooks/roles/junos_info/tasks/main.yml:9
fatal: [10.1.170.9]: FAILED! => {
    "msg": "The task includes an option with an undefined variable. The error was: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'configuration'\n\nThe error appears to have been in '/home/joe/ansible/playbooks/roles/junos_info/tasks/main.yml': line 9, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: print information\n  ^ here\n\nexception type: <class 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute 'configuration'"
}
        to retry, use: --limit @/home/joe/ansible/playbooks/junos_test.retry

PLAY RECAP ****************************************************************************************************************************************************************************************************
10.1.170.9                 : ok=1    changed=0    unreachable=0    failed=1


```



Discussion:
cc @Qalthos @ganeshrn @qalthos
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/lib/ansible/modules/network/junos/junos_facts.py b/lib/ansible/modules/network/junos/junos_facts.py
--- a/lib/ansible/modules/network/junos/junos_facts.py
+++ b/lib/ansible/modules/network/junos/junos_facts.py
@@ -56,6 +56,7 @@
 notes:
   - Ensure I(config_format) used to retrieve configuration from device
     is supported by junos version running on device.
+  - With I(config_format = json), configuration in the results will be a dictionary(and not a JSON string)
   - This module requires the netconf system service be enabled on
     the remote device being managed.
   - Tested against vSRX JUNOS version 15.1X49-D15.4, vqfx-10000 JUNOS Version 15.1X53-D60.4.
@@ -155,7 +156,7 @@ def populate(self):
             config = self.get_text(reply, 'configuration-text')
 
         elif config_format == 'json':
-            config = str(reply.text).strip()
+            config = self.module.from_json(reply.text.strip())
 
         elif config_format == 'set':
             config = self.get_text(reply, 'configuration-set')
@@ -370,7 +371,6 @@ def main():
         else:
             warnings += ['junos-eznc is required to gather old style facts but does not appear to be installed. '
                          'It can be installed using `pip  install junos-eznc`']
-
     module.exit_json(ansible_facts=ansible_facts, warnings=warnings)
 
 


Test patch:
diff --git a/test/integration/targets/junos_facts/tests/netconf/facts.yaml b/test/integration/targets/junos_facts/tests/netconf/facts.yaml
--- a/test/integration/targets/junos_facts/tests/netconf/facts.yaml
+++ b/test/integration/targets/junos_facts/tests/netconf/facts.yaml
@@ -86,7 +86,7 @@
 - assert:
     that:
       - "result.changed == false"
-      - "'\"data\" : \"{{ inventory_hostname_short }}\"' in result['ansible_facts']['ansible_net_config']"
+      - "'{{ inventory_hostname_short }}' == '{{ result['ansible_facts']['ansible_net_config']['configuration'][0]['system'][0]['host-name'][0]['data'] }}' "
 
 - name: Collect config facts from device in text format
   junos_facts:
diff --git a/test/units/modules/network/junos/fixtures/get_configuration_rpc_reply_json.txt b/test/units/modules/network/junos/fixtures/get_configuration_rpc_reply_json.txt
new file mode 100644
--- /dev/null
+++ b/test/units/modules/network/junos/fixtures/get_configuration_rpc_reply_json.txt
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="UTF-8"?><rpc-reply message-id="urn:uuid:72c481b8">
+{
+    "configuration" : [
+    {
+        "system" : [
+        {
+            "host-name" : [
+            {
+                "data" : "vsrx01"
+            }
+            ],
+            "domain-name" : [
+            {
+                "data" : "junos.com"
+            }
+            ],
+            "name-server" : [
+            {
+                "name" :
+                {
+                    "data" : "172.26.1.1"
+                }
+            },
+            {
+                "name" :
+                {
+                    "data" : "8.8.8.8"
+                }
+            }
+            ],
+            "services" : [
+            {
+                "ssh" : [
+                {
+                }
+                ],
+                "telnet" : [
+                {
+                }
+                ],
+                "netconf" : [
+                {
+                    "ssh" : [
+                    {
+                        "port" : [
+                        {
+                            "data" : "830"
+                        }
+                        ]
+                    }
+                    ],
+                    "traceoptions" : [
+                    {
+                        "file" : [
+                        {
+                            "filename" : [
+                            {
+                                "data" : "netconf-ops.log"
+                            }
+                            ]
+                        }
+                        ],
+                        "flag" : [
+                        {
+                            "name" :
+                            {
+                                "data" : "all"
+                            }
+                        }
+                        ]
+                    }
+                    ]
+                }
+                ],
+                "web-management" : [
+                {
+                    "http" : [
+                    {
+                        "interface" : [
+                        {
+                            "data" : "fxp0.0"
+                        }
+                        ]
+                    }
+                    ]
+                }
+                ]
+            }
+            ],
+            "syslog" : [
+            {
+                "user" : [
+                {
+                    "name" :
+                    {
+                        "data" : "*"
+                    },
+                    "contents" : [
+                    {
+                        "name" :
+                        {
+                            "data" : "any"
+                        },
+                        "emergency" : [
+                        {
+                            "data" : null
+                        }
+                        ]
+                    }
+                    ]
+                }
+                ],
+                "file" : [
+                {
+                    "name" :
+                    {
+                        "data" : "messages"
+                    },
+                    "contents" : [
+                    {
+                        "name" :
+                        {
+                            "data" : "any"
+                        },
+                        "any" : [
+                        {
+                            "data" : null
+                        }
+                        ]
+                    },
+                    {
+                        "name" :
+                        {
+                            "data" : "authorization"
+                        },
+                        "info" : [
+                        {
+                            "data" : null
+                        }
+                        ]
+                    }
+                    ]
+                },
+                {
+                    "name" :
+                    {
+                        "data" : "interactive-commands"
+                    },
+                    "contents" : [
+                    {
+                        "name" :
+                        {
+                            "data" : "interactive-commands"
+                        },
+                        "any" : [
+                        {
+                            "data" : null
+                        }
+                        ]
+                    }
+                    ]
+                },
+                {
+                    "name" :
+                    {
+                        "data" : "test1"
+                    },
+                    "contents" : [
+                    {
+                        "name" :
+                        {
+                            "data" : "any"
+                        },
+                        "any" : [
+                        {
+                            "data" : null
+                        }
+                        ]
+                    }
+                    ]
+                }
+                ]
+            }
+            ]
+        }
+	]
+    }
+    ]
+}
+</rpc-reply>
diff --git a/test/units/modules/network/junos/test_junos_facts.py b/test/units/modules/network/junos/test_junos_facts.py
--- a/test/units/modules/network/junos/test_junos_facts.py
+++ b/test/units/modules/network/junos/test_junos_facts.py
@@ -88,6 +88,17 @@ def test_junos_get_facts_subset_config_set(self):
         self.assertEqual(facts['ansible_net_hostname'], 'vsrx01')
         self.assertTrue('ansible_net_interfaces' not in facts)
 
+    def test_junos_get_facts_subset_config_json(self):
+        self.get_config.return_value = load_fixture('get_configuration_rpc_reply_json.txt')
+        set_module_args(dict(gather_subset='config', config_format='json'))
+        result = self.execute_module(format='xml')
+        facts = result['ansible_facts']
+
+        self.assertTrue('ansible_net_config' in facts)
+        self.assertTrue('configuration' in facts['ansible_net_config'])
+        self.assertEqual(facts['ansible_net_hostname'], 'vsrx01')
+        self.assertTrue('ansible_net_interfaces' not in facts)
+
     def test_junos_get_facts_subset_list(self):
         set_module_args(dict(gather_subset=['hardware', 'interfaces']))
         result = self.execute_module(format='xml')