We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Junos Facts Does Not Support "Set" Config Format
<!--- Verify first that your issue/request is not already reported in GitHub -->

##### ISSUE TYPE
<!--- Pick one below and delete the rest: -->
 - Bug Report

##### COMPONENT NAME
<!--- Name of the plugin/module/task -->
`junos_facts`

##### ANSIBLE VERSION
<!--- Paste verbatim output from “ansible --version” between quotes below -->
```
ansible 2.2.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

##### CONFIGURATION
<!---
Mention any settings you have changed/added/removed in ansible.cfg
(or using the ANSIBLE_* environment variables).
-->
N/A

##### 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.
-->
CentOS Linux release 7.2.1511 (Core)

##### SUMMARY
<!--- Explain the problem briefly -->
`junos_facts` does not support the `set` config_format` as stated in http://docs.ansible.com/ansible/junos_facts_module.html

##### STEPS TO REPRODUCE
<!---
For bugs, show exactly how to reproduce the problem.
For new features, show how the feature would be used.
-->
use the following config within a playbook assuming the proper `netconf_auth` is set for your environment.

```
- name: Collect default set of facts and configuration in set format
  register: juniper_config
  junos_facts:
    config: yes
    config_format: set
    port: 22
    provider: "{{ netconf_auth }}"
```

This results in:

```
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml
fatal: [my.router.url]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_reFxNi/ansible_module_junos_facts.py\", line 130, in <module>\n    main()\n  File \"/tmp/ansible_reFxNi/ansible_module_junos_facts.py\", line 117, in main\n    resp_config = module.config.get_config(config_format=config_format)\n  File \"/tmp/ansible_reFxNi/ansible_modlib.zip/ansible/module_utils/netcfg.py\", line 61, in get_config\n  File \"/tmp/ansible_reFxNi/ansible_modlib.zip/ansible/module_utils/junos.py\", line 167, in get_config\n  File \"/tmp/ansible_reFxNi/ansible_modlib.zip/ansible/module_utils/junos.py\", line 93, in raise_exc\nansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml\n", "module_stdout": "", "msg": "MODULE FAILURE"}
```

<!--- Paste example playbooks or commands between quotes below -->
```
- name: Collect default set of facts and configuration in set format
  register: juniper_config
  junos_facts:
    config: yes
    config_format: set
    port: 22
    provider: "{{ netconf_auth }}"
```

<!--- You can also paste gist.github.com links for larger files -->

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
The `junos_facts` module would retrieve the configuration in set format.

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->
An exception is raised stating that the `set` config type is not supported.

<!--- Paste verbatim command output between quotes below -->
```
TASK [router : Collect default set of facts and configuration in set format] ***
task path: /mnt/hgfs/python/backups/ansible/roles/router/tasks/main.yml:26
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/network/junos/junos_facts.py
<my.router.url> ESTABLISH LOCAL CONNECTION FOR USER: myusername
<my.router.url> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035 `" && echo ansible-tmp-1479314958.15-144948237437035="` echo $HOME/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035 `" ) && sleep 0'
<my.router.url> PUT /tmp/tmpbq__s7 TO /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/junos_facts.py
<my.router.url> EXEC /bin/sh -c 'chmod u+x /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/ /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/junos_facts.py && sleep 0'
<my.router.url> EXEC /bin/sh -c '/usr/bin/python /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/junos_facts.py; rm -rf "/home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/" > /dev/null 2>&1 && sleep 0'
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_GCRADR/ansible_module_junos_facts.py", line 130, in <module>
    main()
  File "/tmp/ansible_GCRADR/ansible_module_junos_facts.py", line 117, in main
    resp_config = module.config.get_config(config_format=config_format)
  File "/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/netcfg.py", line 61, in get_config
  File "/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py", line 167, in get_config
  File "/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py", line 93, in raise_exc
ansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml
fatal: [my.router.url]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_name": "junos_facts"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_GCRADR/ansible_module_junos_facts.py\", line 130, in <module>\n    main()\n  File \"/tmp/ansible_GCRADR/ansible_module_junos_facts.py\", line 117, in main\n    resp_config = module.config.get_config(config_format=config_format)\n  File \"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/netcfg.py\", line 61, in get_config\n  File \"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py\", line 167, in get_config\n  File \"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py\", line 93, in raise_exc\nansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `network/junos/junos_facts.py`
Content:
```
1 #!/usr/bin/python
2 #
3 # This file is part of Ansible
4 #
5 # Ansible is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Ansible is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 
19 DOCUMENTATION = """
20 ---
21 module: junos_facts
22 version_added: "2.1"
23 author: "Peter Sprygada (@privateip)"
24 short_description: Collect facts from remote device running Junos
25 description:
26   - Collects fact information from a remote device running the Junos
27     operating system.  By default, the module will collect basic fact
28     information from the device to be included with the hostvars.
29     Additional fact information can be collected based on the
30     configured set of arguments.
31 extends_documentation_fragment: junos
32 options:
33   config:
34     description:
35       - The C(config) argument instructs the fact module to collect
36         the configuration from the remote device.  The configuration
37         is then included in return facts.  By default, the configuration
38         is returned as text.  The C(config_format) can be used to return
39         different Junos configuration formats.
40     required: false
41     default: null
42   config_format:
43     description:
44       - The C(config_format) argument is used to specify the desired
45         format of the configuration file.  Devices support three
46         configuration file formats.  By default, the configuration
47         from the device is returned as text.  The other options include
48         set and xml.  If the xml option is chosen, the configuration file
49         is returned as both xml and json.
50     required: false
51     default: text
52     choices: ['xml', 'text', 'set']
53 requirements:
54   - junos-eznc
55 notes:
56   - This module requires the netconf system service be enabled on
57     the remote device being managed
58 """
59 
60 EXAMPLES = """
61 # the required set of connection arguments have been purposely left off
62 # the examples for brevity
63 
64 - name: collect default set of facts
65   junos_facts:
66 
67 - name: collect default set of facts and configuration
68   junos_facts:
69     config: yes
70 
71 - name: collect default set of facts and configuration in set format
72   junos_facts:
73     config: yes
74     config_format: set
75 
76 - name: collect default set of facts and configuration in XML and JSON format
77   junos_facts:
78     config: yes
79     config_format: xml
80 """
81 
82 RETURN = """
83 ansible_facts:
84   description: Returns the facts collect from the device
85   returned: always
86   type: dict
87 """
88 import ansible.module_utils.junos
89 
90 from ansible.module_utils.network import NetworkModule
91 from ansible.module_utils.junos import xml_to_string, xml_to_json
92 
93 def main():
94     """ Main entry point for AnsibleModule
95     """
96     spec = dict(
97         config=dict(type='bool'),
98         config_format=dict(default='text', choices=['xml', 'set', 'text']),
99         transport=dict(default='netconf', choices=['netconf'])
100     )
101 
102     module = NetworkModule(argument_spec=spec,
103                            supports_check_mode=True)
104 
105     result = dict(changed=False)
106 
107     facts = module.connection.get_facts()
108 
109     if '2RE' in facts:
110         facts['has_2RE'] = facts['2RE']
111         del facts['2RE']
112 
113     facts['version_info'] = dict(facts['version_info'])
114 
115     if module.params['config'] is True:
116         config_format = module.params['config_format']
117         resp_config = module.config.get_config(config_format=config_format)
118 
119         if config_format in ['text', 'set']:
120             facts['config'] = resp_config
121         elif config_format == "xml":
122             facts['config'] = xml_to_string(resp_config)
123             facts['config_json'] = xml_to_json(resp_config)
124 
125     result['ansible_facts'] = facts
126     module.exit_json(**result)
127 
128 
129 if __name__ == '__main__':
130     main()
131
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/network/junos/junos_facts.py b/network/junos/junos_facts.py
--- a/network/junos/junos_facts.py
+++ b/network/junos/junos_facts.py
@@ -44,12 +44,12 @@
       - The C(config_format) argument is used to specify the desired
         format of the configuration file.  Devices support three
         configuration file formats.  By default, the configuration
-        from the device is returned as text.  The other options include
-        set and xml.  If the xml option is chosen, the configuration file
-        is returned as both xml and json.
+        from the device is returned as text.  The other option xml.
+        If the xml option is chosen, the configuration file is 
+        returned as both xml and json.
     required: false
     default: text
-    choices: ['xml', 'text', 'set']
+    choices: ['xml', 'text']
 requirements:
   - junos-eznc
 notes:
@@ -68,10 +68,10 @@
   junos_facts:
     config: yes
 
-- name: collect default set of facts and configuration in set format
+- name: collect default set of facts and configuration in text format
   junos_facts:
     config: yes
-    config_format: set
+    config_format: text
 
 - name: collect default set of facts and configuration in XML and JSON format
   junos_facts:
@@ -95,7 +95,7 @@
     """
     spec = dict(
         config=dict(type='bool'),
-        config_format=dict(default='text', choices=['xml', 'set', 'text']),
+        config_format=dict(default='text', choices=['xml', 'text']),
         transport=dict(default='netconf', choices=['netconf'])
     )
 
@@ -116,7 +116,7 @@
         config_format = module.params['config_format']
         resp_config = module.config.get_config(config_format=config_format)
 
-        if config_format in ['text', 'set']:
+        if config_format in ['text']:
             facts['config'] = resp_config
         elif config_format == "xml":
             facts['config'] = xml_to_string(resp_config)

{"golden_diff": "diff --git a/network/junos/junos_facts.py b/network/junos/junos_facts.py\n--- a/network/junos/junos_facts.py\n+++ b/network/junos/junos_facts.py\n@@ -44,12 +44,12 @@\n       - The C(config_format) argument is used to specify the desired\n         format of the configuration file.  Devices support three\n         configuration file formats.  By default, the configuration\n-        from the device is returned as text.  The other options include\n-        set and xml.  If the xml option is chosen, the configuration file\n-        is returned as both xml and json.\n+        from the device is returned as text.  The other option xml.\n+        If the xml option is chosen, the configuration file is \n+        returned as both xml and json.\n     required: false\n     default: text\n-    choices: ['xml', 'text', 'set']\n+    choices: ['xml', 'text']\n requirements:\n   - junos-eznc\n notes:\n@@ -68,10 +68,10 @@\n   junos_facts:\n     config: yes\n \n-- name: collect default set of facts and configuration in set format\n+- name: collect default set of facts and configuration in text format\n   junos_facts:\n     config: yes\n-    config_format: set\n+    config_format: text\n \n - name: collect default set of facts and configuration in XML and JSON format\n   junos_facts:\n@@ -95,7 +95,7 @@\n     \"\"\"\n     spec = dict(\n         config=dict(type='bool'),\n-        config_format=dict(default='text', choices=['xml', 'set', 'text']),\n+        config_format=dict(default='text', choices=['xml', 'text']),\n         transport=dict(default='netconf', choices=['netconf'])\n     )\n \n@@ -116,7 +116,7 @@\n         config_format = module.params['config_format']\n         resp_config = module.config.get_config(config_format=config_format)\n \n-        if config_format in ['text', 'set']:\n+        if config_format in ['text']:\n             facts['config'] = resp_config\n         elif config_format == \"xml\":\n             facts['config'] = xml_to_string(resp_config)\n", "issue": "Junos Facts Does Not Support \"Set\" Config Format\n<!--- Verify first that your issue/request is not already reported in GitHub -->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Name of the plugin/module/task -->\r\n`junos_facts`\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from \u201cansible --version\u201d between quotes below -->\r\n```\r\nansible 2.2.0.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\nMention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\nN/A\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nMention the OS you are running Ansible from, and the OS you are\r\nmanaging, or say \u201cN/A\u201d for anything that is not platform-specific.\r\n-->\r\nCentOS Linux release 7.2.1511 (Core)\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\n`junos_facts` does not support the `set` config_format` as stated in http://docs.ansible.com/ansible/junos_facts_module.html\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem.\r\nFor new features, show how the feature would be used.\r\n-->\r\nuse the following config within a playbook assuming the proper `netconf_auth` is set for your environment.\r\n\r\n```\r\n- name: Collect default set of facts and configuration in set format\r\n  register: juniper_config\r\n  junos_facts:\r\n    config: yes\r\n    config_format: set\r\n    port: 22\r\n    provider: \"{{ netconf_auth }}\"\r\n```\r\n\r\nThis results in:\r\n\r\n```\r\nAn exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml\r\nfatal: [my.router.url]: FAILED! => {\"changed\": false, \"failed\": true, \"module_stderr\": \"Traceback (most recent call last):\\n  File \\\"/tmp/ansible_reFxNi/ansible_module_junos_facts.py\\\", line 130, in <module>\\n    main()\\n  File \\\"/tmp/ansible_reFxNi/ansible_module_junos_facts.py\\\", line 117, in main\\n    resp_config = module.config.get_config(config_format=config_format)\\n  File \\\"/tmp/ansible_reFxNi/ansible_modlib.zip/ansible/module_utils/netcfg.py\\\", line 61, in get_config\\n  File \\\"/tmp/ansible_reFxNi/ansible_modlib.zip/ansible/module_utils/junos.py\\\", line 167, in get_config\\n  File \\\"/tmp/ansible_reFxNi/ansible_modlib.zip/ansible/module_utils/junos.py\\\", line 93, in raise_exc\\nansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml\\n\", \"module_stdout\": \"\", \"msg\": \"MODULE FAILURE\"}\r\n```\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n- name: Collect default set of facts and configuration in set format\r\n  register: juniper_config\r\n  junos_facts:\r\n    config: yes\r\n    config_format: set\r\n    port: 22\r\n    provider: \"{{ netconf_auth }}\"\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\nThe `junos_facts` module would retrieve the configuration in set format.\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\nAn exception is raised stating that the `set` config type is not supported.\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\nTASK [router : Collect default set of facts and configuration in set format] ***\r\ntask path: /mnt/hgfs/python/backups/ansible/roles/router/tasks/main.yml:26\r\nUsing module file /usr/lib/python2.7/site-packages/ansible/modules/core/network/junos/junos_facts.py\r\n<my.router.url> ESTABLISH LOCAL CONNECTION FOR USER: myusername\r\n<my.router.url> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo $HOME/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035 `\" && echo ansible-tmp-1479314958.15-144948237437035=\"` echo $HOME/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035 `\" ) && sleep 0'\r\n<my.router.url> PUT /tmp/tmpbq__s7 TO /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/junos_facts.py\r\n<my.router.url> EXEC /bin/sh -c 'chmod u+x /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/ /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/junos_facts.py && sleep 0'\r\n<my.router.url> EXEC /bin/sh -c '/usr/bin/python /home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/junos_facts.py; rm -rf \"/home/myusername/.ansible/tmp/ansible-tmp-1479314958.15-144948237437035/\" > /dev/null 2>&1 && sleep 0'\r\nAn exception occurred during task execution. The full traceback is:\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_GCRADR/ansible_module_junos_facts.py\", line 130, in <module>\r\n    main()\r\n  File \"/tmp/ansible_GCRADR/ansible_module_junos_facts.py\", line 117, in main\r\n    resp_config = module.config.get_config(config_format=config_format)\r\n  File \"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/netcfg.py\", line 61, in get_config\r\n  File \"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py\", line 167, in get_config\r\n  File \"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py\", line 93, in raise_exc\r\nansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml\r\nfatal: [my.router.url]: FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"invocation\": {\r\n        \"module_name\": \"junos_facts\"\r\n    }, \r\n    \"module_stderr\": \"Traceback (most recent call last):\\n  File \\\"/tmp/ansible_GCRADR/ansible_module_junos_facts.py\\\", line 130, in <module>\\n    main()\\n  File \\\"/tmp/ansible_GCRADR/ansible_module_junos_facts.py\\\", line 117, in main\\n    resp_config = module.config.get_config(config_format=config_format)\\n  File \\\"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/netcfg.py\\\", line 61, in get_config\\n  File \\\"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py\\\", line 167, in get_config\\n  File \\\"/tmp/ansible_GCRADR/ansible_modlib.zip/ansible/module_utils/junos.py\\\", line 93, in raise_exc\\nansible.module_utils.network.NetworkError: invalid config format.  Valid options are text, xml\\n\", \r\n    \"module_stdout\": \"\", \r\n    \"msg\": \"MODULE FAILURE\"\r\n}\r\n```\r\n\n", "before_files": [{"content": "#!/usr/bin/python\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n#\n\nDOCUMENTATION = \"\"\"\n---\nmodule: junos_facts\nversion_added: \"2.1\"\nauthor: \"Peter Sprygada (@privateip)\"\nshort_description: Collect facts from remote device running Junos\ndescription:\n  - Collects fact information from a remote device running the Junos\n    operating system.  By default, the module will collect basic fact\n    information from the device to be included with the hostvars.\n    Additional fact information can be collected based on the\n    configured set of arguments.\nextends_documentation_fragment: junos\noptions:\n  config:\n    description:\n      - The C(config) argument instructs the fact module to collect\n        the configuration from the remote device.  The configuration\n        is then included in return facts.  By default, the configuration\n        is returned as text.  The C(config_format) can be used to return\n        different Junos configuration formats.\n    required: false\n    default: null\n  config_format:\n    description:\n      - The C(config_format) argument is used to specify the desired\n        format of the configuration file.  Devices support three\n        configuration file formats.  By default, the configuration\n        from the device is returned as text.  The other options include\n        set and xml.  If the xml option is chosen, the configuration file\n        is returned as both xml and json.\n    required: false\n    default: text\n    choices: ['xml', 'text', 'set']\nrequirements:\n  - junos-eznc\nnotes:\n  - This module requires the netconf system service be enabled on\n    the remote device being managed\n\"\"\"\n\nEXAMPLES = \"\"\"\n# the required set of connection arguments have been purposely left off\n# the examples for brevity\n\n- name: collect default set of facts\n  junos_facts:\n\n- name: collect default set of facts and configuration\n  junos_facts:\n    config: yes\n\n- name: collect default set of facts and configuration in set format\n  junos_facts:\n    config: yes\n    config_format: set\n\n- name: collect default set of facts and configuration in XML and JSON format\n  junos_facts:\n    config: yes\n    config_format: xml\n\"\"\"\n\nRETURN = \"\"\"\nansible_facts:\n  description: Returns the facts collect from the device\n  returned: always\n  type: dict\n\"\"\"\nimport ansible.module_utils.junos\n\nfrom ansible.module_utils.network import NetworkModule\nfrom ansible.module_utils.junos import xml_to_string, xml_to_json\n\ndef main():\n    \"\"\" Main entry point for AnsibleModule\n    \"\"\"\n    spec = dict(\n        config=dict(type='bool'),\n        config_format=dict(default='text', choices=['xml', 'set', 'text']),\n        transport=dict(default='netconf', choices=['netconf'])\n    )\n\n    module = NetworkModule(argument_spec=spec,\n                           supports_check_mode=True)\n\n    result = dict(changed=False)\n\n    facts = module.connection.get_facts()\n\n    if '2RE' in facts:\n        facts['has_2RE'] = facts['2RE']\n        del facts['2RE']\n\n    facts['version_info'] = dict(facts['version_info'])\n\n    if module.params['config'] is True:\n        config_format = module.params['config_format']\n        resp_config = module.config.get_config(config_format=config_format)\n\n        if config_format in ['text', 'set']:\n            facts['config'] = resp_config\n        elif config_format == \"xml\":\n            facts['config'] = xml_to_string(resp_config)\n            facts['config_json'] = xml_to_json(resp_config)\n\n    result['ansible_facts'] = facts\n    module.exit_json(**result)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "network/junos/junos_facts.py"}], "after_files": [{"content": "#!/usr/bin/python\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n#\n\nDOCUMENTATION = \"\"\"\n---\nmodule: junos_facts\nversion_added: \"2.1\"\nauthor: \"Peter Sprygada (@privateip)\"\nshort_description: Collect facts from remote device running Junos\ndescription:\n  - Collects fact information from a remote device running the Junos\n    operating system.  By default, the module will collect basic fact\n    information from the device to be included with the hostvars.\n    Additional fact information can be collected based on the\n    configured set of arguments.\nextends_documentation_fragment: junos\noptions:\n  config:\n    description:\n      - The C(config) argument instructs the fact module to collect\n        the configuration from the remote device.  The configuration\n        is then included in return facts.  By default, the configuration\n        is returned as text.  The C(config_format) can be used to return\n        different Junos configuration formats.\n    required: false\n    default: null\n  config_format:\n    description:\n      - The C(config_format) argument is used to specify the desired\n        format of the configuration file.  Devices support three\n        configuration file formats.  By default, the configuration\n        from the device is returned as text.  The other option xml.\n        If the xml option is chosen, the configuration file is \n        returned as both xml and json.\n    required: false\n    default: text\n    choices: ['xml', 'text']\nrequirements:\n  - junos-eznc\nnotes:\n  - This module requires the netconf system service be enabled on\n    the remote device being managed\n\"\"\"\n\nEXAMPLES = \"\"\"\n# the required set of connection arguments have been purposely left off\n# the examples for brevity\n\n- name: collect default set of facts\n  junos_facts:\n\n- name: collect default set of facts and configuration\n  junos_facts:\n    config: yes\n\n- name: collect default set of facts and configuration in text format\n  junos_facts:\n    config: yes\n    config_format: text\n\n- name: collect default set of facts and configuration in XML and JSON format\n  junos_facts:\n    config: yes\n    config_format: xml\n\"\"\"\n\nRETURN = \"\"\"\nansible_facts:\n  description: Returns the facts collect from the device\n  returned: always\n  type: dict\n\"\"\"\nimport ansible.module_utils.junos\n\nfrom ansible.module_utils.network import NetworkModule\nfrom ansible.module_utils.junos import xml_to_string, xml_to_json\n\ndef main():\n    \"\"\" Main entry point for AnsibleModule\n    \"\"\"\n    spec = dict(\n        config=dict(type='bool'),\n        config_format=dict(default='text', choices=['xml', 'text']),\n        transport=dict(default='netconf', choices=['netconf'])\n    )\n\n    module = NetworkModule(argument_spec=spec,\n                           supports_check_mode=True)\n\n    result = dict(changed=False)\n\n    facts = module.connection.get_facts()\n\n    if '2RE' in facts:\n        facts['has_2RE'] = facts['2RE']\n        del facts['2RE']\n\n    facts['version_info'] = dict(facts['version_info'])\n\n    if module.params['config'] is True:\n        config_format = module.params['config_format']\n        resp_config = module.config.get_config(config_format=config_format)\n\n        if config_format in ['text']:\n            facts['config'] = resp_config\n        elif config_format == \"xml\":\n            facts['config'] = xml_to_string(resp_config)\n            facts['config_json'] = xml_to_json(resp_config)\n\n    result['ansible_facts'] = facts\n    module.exit_json(**result)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "network/junos/junos_facts.py"}]}