We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add support for "cpanm --mirror-only"
##### Issue Type:

Feature Idea
##### Ansible Version:

1.7.2
##### Environment:

Ubuntu, but this goes for any environment.
##### Summary:

It would be great if it was possible to specify `mirror_only=yes` in the cpanm module. This enable installs from [minicpan](https://metacpan.org/pod/CPAN::Mini) in a local environment where extra packages has been injected.

Example:

```
cpanm --mirror-only --mirror http://cpan.myinternal.net My::Custom::Module
```

Without "--mirror-only", cpanm will try to lookup My::Custom::Module in CPAN Meta DB.
##### Steps To Reproduce:
##### Expected Results:
##### Actual Results:


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `packaging/language/cpanm.py`
Content:
```
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3 
4 # (c) 2012, Franck Cuny <franck@lumberjaph.net>
5 #
6 # This file is part of Ansible
7 #
8 # Ansible is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Ansible is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
20 #
21 
22 DOCUMENTATION = '''
23 ---
24 module: cpanm
25 short_description: Manages Perl library dependencies.
26 description:
27   - Manage Perl library dependencies.
28 version_added: "1.6"
29 options:
30   name:
31     description:
32       - The name of the Perl library to install. You may use the "full distribution path", e.g.  MIYAGAWA/Plack-0.99_05.tar.gz
33     required: false
34     default: null
35     aliases: ["pkg"]
36   from_path:
37     description:
38       - The local directory from where to install
39     required: false
40     default: null
41   notest:
42     description:
43       - Do not run unit tests
44     required: false
45     default: false
46   locallib:
47     description:
48       - Specify the install base to install modules
49     required: false
50     default: false
51   mirror:
52     description:
53       - Specifies the base URL for the CPAN mirror to use
54     required: false
55     default: false
56 examples:
57    - code: "cpanm: name=Dancer"
58      description: Install I(Dancer) perl package.
59    - code: "cpanm: name=MIYAGAWA/Plack-0.99_05.tar.gz"
60      description: Install version 0.99_05 of the I(Plack) perl package.
61    - code: "cpanm: name=Dancer locallib=/srv/webapps/my_app/extlib"
62      description: "Install I(Dancer) (U(http://perldancer.org/)) into the specified I(locallib)"
63    - code: "cpanm: from_path=/srv/webapps/my_app/src/"
64      description: Install perl dependencies from local directory.
65    - code: "cpanm: name=Dancer notest=True locallib=/srv/webapps/my_app/extlib"
66      description: Install I(Dancer) perl package without running the unit tests in indicated I(locallib).
67    - code: "cpanm: name=Dancer mirror=http://cpan.cpantesters.org/"
68      description: Install I(Dancer) perl package from a specific mirror
69 notes:
70    - Please note that U(http://search.cpan.org/dist/App-cpanminus/bin/cpanm, cpanm) must be installed on the remote host.
71 author: Franck Cuny
72 '''
73 
74 def _is_package_installed(module, name, locallib, cpanm):
75     cmd = ""
76     if locallib:
77         os.environ["PERL5LIB"] = "%s/lib/perl5" % locallib
78     cmd = "%s perl -M%s -e '1'" % (cmd, name)
79     res, stdout, stderr = module.run_command(cmd, check_rc=False)
80     if res == 0:
81        return True
82     else: 
83        return False
84 
85 def _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm):
86     # this code should use "%s" like everything else and just return early but not fixing all of it now.
87     # don't copy stuff like this
88     if from_path:
89         cmd = "{cpanm} {path}".format(cpanm=cpanm, path=from_path)
90     else:
91         cmd = "{cpanm} {name}".format(cpanm=cpanm, name=name)
92 
93     if notest is True:
94         cmd = "{cmd} -n".format(cmd=cmd)
95 
96     if locallib is not None:
97         cmd = "{cmd} -l {locallib}".format(cmd=cmd, locallib=locallib)
98 
99     if mirror is not None:
100         cmd = "{cmd} --mirror {mirror}".format(cmd=cmd, mirror=mirror)
101 
102     return cmd
103 
104 
105 def main():
106     arg_spec = dict(
107         name=dict(default=None, required=False, aliases=['pkg']),
108         from_path=dict(default=None, required=False),
109         notest=dict(default=False, type='bool'),
110         locallib=dict(default=None, required=False),
111         mirror=dict(default=None, required=False)
112     )
113 
114     module = AnsibleModule(
115         argument_spec=arg_spec,
116         required_one_of=[['name', 'from_path']],
117     )
118 
119     cpanm     = module.get_bin_path('cpanm', True)
120     name      = module.params['name']
121     from_path = module.params['from_path']
122     notest    = module.boolean(module.params.get('notest', False))
123     locallib  = module.params['locallib']
124     mirror    = module.params['mirror']
125 
126     changed   = False
127 
128     installed = _is_package_installed(module, name, locallib, cpanm)
129 
130     if not installed:
131         out_cpanm = err_cpanm = ''
132         cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm)
133 
134         rc_cpanm, out_cpanm, err_cpanm = module.run_command(cmd, check_rc=False)
135 
136         if rc_cpanm != 0:
137             module.fail_json(msg=err_cpanm, cmd=cmd)
138 
139         if err_cpanm and 'is up to date' not in err_cpanm:
140             changed = True
141 
142     module.exit_json(changed=changed, binary=cpanm, name=name)
143 
144 # import module snippets
145 from ansible.module_utils.basic import *
146 
147 main()
148
```
--- 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/packaging/language/cpanm.py b/packaging/language/cpanm.py
--- a/packaging/language/cpanm.py
+++ b/packaging/language/cpanm.py
@@ -53,6 +53,11 @@
       - Specifies the base URL for the CPAN mirror to use
     required: false
     default: false
+  mirror_only:
+    description:
+      - Use the mirror's index file instead of the CPAN Meta DB
+    required: false
+    default: false
 examples:
    - code: "cpanm: name=Dancer"
      description: Install I(Dancer) perl package.
@@ -82,7 +87,7 @@
     else: 
        return False
 
-def _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm):
+def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm):
     # this code should use "%s" like everything else and just return early but not fixing all of it now.
     # don't copy stuff like this
     if from_path:
@@ -99,6 +104,9 @@
     if mirror is not None:
         cmd = "{cmd} --mirror {mirror}".format(cmd=cmd, mirror=mirror)
 
+    if mirror_only is True:
+        cmd = "{cmd} --mirror-only".format(cmd=cmd)
+
     return cmd
 
 
@@ -109,6 +117,7 @@
         notest=dict(default=False, type='bool'),
         locallib=dict(default=None, required=False),
         mirror=dict(default=None, required=False)
+        mirror_only=dict(default=False, type='bool'),
     )
 
     module = AnsibleModule(
@@ -116,12 +125,13 @@
         required_one_of=[['name', 'from_path']],
     )
 
-    cpanm     = module.get_bin_path('cpanm', True)
-    name      = module.params['name']
-    from_path = module.params['from_path']
-    notest    = module.boolean(module.params.get('notest', False))
-    locallib  = module.params['locallib']
-    mirror    = module.params['mirror']
+    cpanm       = module.get_bin_path('cpanm', True)
+    name        = module.params['name']
+    from_path   = module.params['from_path']
+    notest      = module.boolean(module.params.get('notest', False))
+    locallib    = module.params['locallib']
+    mirror      = module.params['mirror']
+    mirror_only = module.params['mirror_only']
 
     changed   = False
 
@@ -129,7 +139,7 @@
 
     if not installed:
         out_cpanm = err_cpanm = ''
-        cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm)
+        cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm)
 
         rc_cpanm, out_cpanm, err_cpanm = module.run_command(cmd, check_rc=False)

{"golden_diff": "diff --git a/packaging/language/cpanm.py b/packaging/language/cpanm.py\n--- a/packaging/language/cpanm.py\n+++ b/packaging/language/cpanm.py\n@@ -53,6 +53,11 @@\n       - Specifies the base URL for the CPAN mirror to use\n     required: false\n     default: false\n+  mirror_only:\n+    description:\n+      - Use the mirror's index file instead of the CPAN Meta DB\n+    required: false\n+    default: false\n examples:\n    - code: \"cpanm: name=Dancer\"\n      description: Install I(Dancer) perl package.\n@@ -82,7 +87,7 @@\n     else: \n        return False\n \n-def _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm):\n+def _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm):\n     # this code should use \"%s\" like everything else and just return early but not fixing all of it now.\n     # don't copy stuff like this\n     if from_path:\n@@ -99,6 +104,9 @@\n     if mirror is not None:\n         cmd = \"{cmd} --mirror {mirror}\".format(cmd=cmd, mirror=mirror)\n \n+    if mirror_only is True:\n+        cmd = \"{cmd} --mirror-only\".format(cmd=cmd)\n+\n     return cmd\n \n \n@@ -109,6 +117,7 @@\n         notest=dict(default=False, type='bool'),\n         locallib=dict(default=None, required=False),\n         mirror=dict(default=None, required=False)\n+        mirror_only=dict(default=False, type='bool'),\n     )\n \n     module = AnsibleModule(\n@@ -116,12 +125,13 @@\n         required_one_of=[['name', 'from_path']],\n     )\n \n-    cpanm     = module.get_bin_path('cpanm', True)\n-    name      = module.params['name']\n-    from_path = module.params['from_path']\n-    notest    = module.boolean(module.params.get('notest', False))\n-    locallib  = module.params['locallib']\n-    mirror    = module.params['mirror']\n+    cpanm       = module.get_bin_path('cpanm', True)\n+    name        = module.params['name']\n+    from_path   = module.params['from_path']\n+    notest      = module.boolean(module.params.get('notest', False))\n+    locallib    = module.params['locallib']\n+    mirror      = module.params['mirror']\n+    mirror_only = module.params['mirror_only']\n \n     changed   = False\n \n@@ -129,7 +139,7 @@\n \n     if not installed:\n         out_cpanm = err_cpanm = ''\n-        cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm)\n+        cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm)\n \n         rc_cpanm, out_cpanm, err_cpanm = module.run_command(cmd, check_rc=False)\n", "issue": "Add support for \"cpanm --mirror-only\"\n##### Issue Type:\n\nFeature Idea\n##### Ansible Version:\n\n1.7.2\n##### Environment:\n\nUbuntu, but this goes for any environment.\n##### Summary:\n\nIt would be great if it was possible to specify `mirror_only=yes` in the cpanm module. This enable installs from [minicpan](https://metacpan.org/pod/CPAN::Mini) in a local environment where extra packages has been injected.\n\nExample:\n\n```\ncpanm --mirror-only --mirror http://cpan.myinternal.net My::Custom::Module\n```\n\nWithout \"--mirror-only\", cpanm will try to lookup My::Custom::Module in CPAN Meta DB.\n##### Steps To Reproduce:\n##### Expected Results:\n##### Actual Results:\n\n", "before_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# (c) 2012, Franck Cuny <franck@lumberjaph.net>\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: cpanm\nshort_description: Manages Perl library dependencies.\ndescription:\n  - Manage Perl library dependencies.\nversion_added: \"1.6\"\noptions:\n  name:\n    description:\n      - The name of the Perl library to install. You may use the \"full distribution path\", e.g.  MIYAGAWA/Plack-0.99_05.tar.gz\n    required: false\n    default: null\n    aliases: [\"pkg\"]\n  from_path:\n    description:\n      - The local directory from where to install\n    required: false\n    default: null\n  notest:\n    description:\n      - Do not run unit tests\n    required: false\n    default: false\n  locallib:\n    description:\n      - Specify the install base to install modules\n    required: false\n    default: false\n  mirror:\n    description:\n      - Specifies the base URL for the CPAN mirror to use\n    required: false\n    default: false\nexamples:\n   - code: \"cpanm: name=Dancer\"\n     description: Install I(Dancer) perl package.\n   - code: \"cpanm: name=MIYAGAWA/Plack-0.99_05.tar.gz\"\n     description: Install version 0.99_05 of the I(Plack) perl package.\n   - code: \"cpanm: name=Dancer locallib=/srv/webapps/my_app/extlib\"\n     description: \"Install I(Dancer) (U(http://perldancer.org/)) into the specified I(locallib)\"\n   - code: \"cpanm: from_path=/srv/webapps/my_app/src/\"\n     description: Install perl dependencies from local directory.\n   - code: \"cpanm: name=Dancer notest=True locallib=/srv/webapps/my_app/extlib\"\n     description: Install I(Dancer) perl package without running the unit tests in indicated I(locallib).\n   - code: \"cpanm: name=Dancer mirror=http://cpan.cpantesters.org/\"\n     description: Install I(Dancer) perl package from a specific mirror\nnotes:\n   - Please note that U(http://search.cpan.org/dist/App-cpanminus/bin/cpanm, cpanm) must be installed on the remote host.\nauthor: Franck Cuny\n'''\n\ndef _is_package_installed(module, name, locallib, cpanm):\n    cmd = \"\"\n    if locallib:\n        os.environ[\"PERL5LIB\"] = \"%s/lib/perl5\" % locallib\n    cmd = \"%s perl -M%s -e '1'\" % (cmd, name)\n    res, stdout, stderr = module.run_command(cmd, check_rc=False)\n    if res == 0:\n       return True\n    else: \n       return False\n\ndef _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm):\n    # this code should use \"%s\" like everything else and just return early but not fixing all of it now.\n    # don't copy stuff like this\n    if from_path:\n        cmd = \"{cpanm} {path}\".format(cpanm=cpanm, path=from_path)\n    else:\n        cmd = \"{cpanm} {name}\".format(cpanm=cpanm, name=name)\n\n    if notest is True:\n        cmd = \"{cmd} -n\".format(cmd=cmd)\n\n    if locallib is not None:\n        cmd = \"{cmd} -l {locallib}\".format(cmd=cmd, locallib=locallib)\n\n    if mirror is not None:\n        cmd = \"{cmd} --mirror {mirror}\".format(cmd=cmd, mirror=mirror)\n\n    return cmd\n\n\ndef main():\n    arg_spec = dict(\n        name=dict(default=None, required=False, aliases=['pkg']),\n        from_path=dict(default=None, required=False),\n        notest=dict(default=False, type='bool'),\n        locallib=dict(default=None, required=False),\n        mirror=dict(default=None, required=False)\n    )\n\n    module = AnsibleModule(\n        argument_spec=arg_spec,\n        required_one_of=[['name', 'from_path']],\n    )\n\n    cpanm     = module.get_bin_path('cpanm', True)\n    name      = module.params['name']\n    from_path = module.params['from_path']\n    notest    = module.boolean(module.params.get('notest', False))\n    locallib  = module.params['locallib']\n    mirror    = module.params['mirror']\n\n    changed   = False\n\n    installed = _is_package_installed(module, name, locallib, cpanm)\n\n    if not installed:\n        out_cpanm = err_cpanm = ''\n        cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, cpanm)\n\n        rc_cpanm, out_cpanm, err_cpanm = module.run_command(cmd, check_rc=False)\n\n        if rc_cpanm != 0:\n            module.fail_json(msg=err_cpanm, cmd=cmd)\n\n        if err_cpanm and 'is up to date' not in err_cpanm:\n            changed = True\n\n    module.exit_json(changed=changed, binary=cpanm, name=name)\n\n# import module snippets\nfrom ansible.module_utils.basic import *\n\nmain()\n", "path": "packaging/language/cpanm.py"}], "after_files": [{"content": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# (c) 2012, Franck Cuny <franck@lumberjaph.net>\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: cpanm\nshort_description: Manages Perl library dependencies.\ndescription:\n  - Manage Perl library dependencies.\nversion_added: \"1.6\"\noptions:\n  name:\n    description:\n      - The name of the Perl library to install. You may use the \"full distribution path\", e.g.  MIYAGAWA/Plack-0.99_05.tar.gz\n    required: false\n    default: null\n    aliases: [\"pkg\"]\n  from_path:\n    description:\n      - The local directory from where to install\n    required: false\n    default: null\n  notest:\n    description:\n      - Do not run unit tests\n    required: false\n    default: false\n  locallib:\n    description:\n      - Specify the install base to install modules\n    required: false\n    default: false\n  mirror:\n    description:\n      - Specifies the base URL for the CPAN mirror to use\n    required: false\n    default: false\n  mirror_only:\n    description:\n      - Use the mirror's index file instead of the CPAN Meta DB\n    required: false\n    default: false\nexamples:\n   - code: \"cpanm: name=Dancer\"\n     description: Install I(Dancer) perl package.\n   - code: \"cpanm: name=MIYAGAWA/Plack-0.99_05.tar.gz\"\n     description: Install version 0.99_05 of the I(Plack) perl package.\n   - code: \"cpanm: name=Dancer locallib=/srv/webapps/my_app/extlib\"\n     description: \"Install I(Dancer) (U(http://perldancer.org/)) into the specified I(locallib)\"\n   - code: \"cpanm: from_path=/srv/webapps/my_app/src/\"\n     description: Install perl dependencies from local directory.\n   - code: \"cpanm: name=Dancer notest=True locallib=/srv/webapps/my_app/extlib\"\n     description: Install I(Dancer) perl package without running the unit tests in indicated I(locallib).\n   - code: \"cpanm: name=Dancer mirror=http://cpan.cpantesters.org/\"\n     description: Install I(Dancer) perl package from a specific mirror\nnotes:\n   - Please note that U(http://search.cpan.org/dist/App-cpanminus/bin/cpanm, cpanm) must be installed on the remote host.\nauthor: Franck Cuny\n'''\n\ndef _is_package_installed(module, name, locallib, cpanm):\n    cmd = \"\"\n    if locallib:\n        os.environ[\"PERL5LIB\"] = \"%s/lib/perl5\" % locallib\n    cmd = \"%s perl -M%s -e '1'\" % (cmd, name)\n    res, stdout, stderr = module.run_command(cmd, check_rc=False)\n    if res == 0:\n       return True\n    else: \n       return False\n\ndef _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm):\n    # this code should use \"%s\" like everything else and just return early but not fixing all of it now.\n    # don't copy stuff like this\n    if from_path:\n        cmd = \"{cpanm} {path}\".format(cpanm=cpanm, path=from_path)\n    else:\n        cmd = \"{cpanm} {name}\".format(cpanm=cpanm, name=name)\n\n    if notest is True:\n        cmd = \"{cmd} -n\".format(cmd=cmd)\n\n    if locallib is not None:\n        cmd = \"{cmd} -l {locallib}\".format(cmd=cmd, locallib=locallib)\n\n    if mirror is not None:\n        cmd = \"{cmd} --mirror {mirror}\".format(cmd=cmd, mirror=mirror)\n\n    if mirror_only is True:\n        cmd = \"{cmd} --mirror-only\".format(cmd=cmd)\n\n    return cmd\n\n\ndef main():\n    arg_spec = dict(\n        name=dict(default=None, required=False, aliases=['pkg']),\n        from_path=dict(default=None, required=False),\n        notest=dict(default=False, type='bool'),\n        locallib=dict(default=None, required=False),\n        mirror=dict(default=None, required=False)\n        mirror_only=dict(default=False, type='bool'),\n    )\n\n    module = AnsibleModule(\n        argument_spec=arg_spec,\n        required_one_of=[['name', 'from_path']],\n    )\n\n    cpanm       = module.get_bin_path('cpanm', True)\n    name        = module.params['name']\n    from_path   = module.params['from_path']\n    notest      = module.boolean(module.params.get('notest', False))\n    locallib    = module.params['locallib']\n    mirror      = module.params['mirror']\n    mirror_only = module.params['mirror_only']\n\n    changed   = False\n\n    installed = _is_package_installed(module, name, locallib, cpanm)\n\n    if not installed:\n        out_cpanm = err_cpanm = ''\n        cmd       = _build_cmd_line(name, from_path, notest, locallib, mirror, mirror_only, cpanm)\n\n        rc_cpanm, out_cpanm, err_cpanm = module.run_command(cmd, check_rc=False)\n\n        if rc_cpanm != 0:\n            module.fail_json(msg=err_cpanm, cmd=cmd)\n\n        if err_cpanm and 'is up to date' not in err_cpanm:\n            changed = True\n\n    module.exit_json(changed=changed, binary=cpanm, name=name)\n\n# import module snippets\nfrom ansible.module_utils.basic import *\n\nmain()\n", "path": "packaging/language/cpanm.py"}]}