We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ad_hoc_command: execution_environment option is ignored
### Please confirm the following

- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).
- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.
- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.
- [X] I am **NOT** reporting a (potential) security vulnerability. (These should be emailed to `security@ansible.com` instead.)

### Bug Summary

The `execution_environment` option in `ad_hoc_command` module is ignored and runs with the default EE (`AWX EE (latest)`).



### AWX version

22.3.0

### Select the relevant components

- [ ] UI
- [ ] UI (tech preview)
- [ ] API
- [ ] Docs
- [X] Collection
- [ ] CLI
- [ ] Other

### Installation method

N/A

### Modifications

no

### Ansible version

_No response_

### Operating system

_No response_

### Web browser

_No response_

### Steps to reproduce



Run with `execution_environment` option in the `awx.awx.ad_hoc_command` module. As in the following Playbook.

```yaml
    - name: Ad Hoc command test
      awx.awx.ad_hoc_command:
        inventory: Demo Inventory
        credential: Demo Credential 
        module_name: command
        module_args: echo I <3 Ansible
        execution_environment: my_ee
        wait: true
````


### Expected results

Runs in the execution environment specified by the execution_environment option.


### Actual results

The execution_environment option is ignored and runs with the default EE (`AWX EE (latest)`).

### Additional information

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `awx_collection/plugins/modules/ad_hoc_command.py`
Content:
```
1 #!/usr/bin/python
2 # coding: utf-8 -*-
3 
4 
5 # (c) 2020, John Westcott IV <john.westcott.iv@redhat.com>
6 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
7 
8 from __future__ import absolute_import, division, print_function
9 
10 __metaclass__ = type
11 
12 
13 ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
14 
15 DOCUMENTATION = '''
16 ---
17 module: ad_hoc_command
18 author: "John Westcott IV (@john-westcott-iv)"
19 version_added: "4.0.0"
20 short_description: create, update, or destroy Automation Platform Controller ad hoc commands.
21 description:
22     - Create, update, or destroy Automation Platform Controller ad hoc commands. See
23       U(https://www.ansible.com/tower) for an overview.
24 options:
25     job_type:
26       description:
27         - Job_type to use for the ad hoc command.
28       type: str
29       choices: [ 'run', 'check' ]
30     execution_environment:
31       description:
32         - Execution Environment to use for the ad hoc command.
33       required: False
34       type: str
35     inventory:
36       description:
37         - Inventory to use for the ad hoc command.
38       required: True
39       type: str
40     limit:
41       description:
42         - Limit to use for the ad hoc command.
43       type: str
44     credential:
45       description:
46         - Credential to use for ad hoc command.
47       required: True
48       type: str
49     module_name:
50       description:
51         - The Ansible module to execute.
52       required: True
53       type: str
54     module_args:
55       description:
56         - The arguments to pass to the module.
57       type: str
58     forks:
59       description:
60         - The number of forks to use for this ad hoc execution.
61       type: int
62     verbosity:
63       description:
64         - Verbosity level for this ad hoc command run
65       type: int
66       choices: [ 0, 1, 2, 3, 4, 5 ]
67     extra_vars:
68       description:
69         - Extra variables to use for the ad hoc command..
70       type: dict
71     become_enabled:
72       description:
73         - If the become flag should be set.
74       type: bool
75     diff_mode:
76       description:
77         - Show the changes made by Ansible tasks where supported
78       type: bool
79     wait:
80       description:
81         - Wait for the command to complete.
82       default: False
83       type: bool
84     interval:
85       description:
86         - The interval to request an update from the controller.
87       default: 2
88       type: float
89     timeout:
90       description:
91         - If waiting for the command to complete this will abort after this
92           amount of seconds
93       type: int
94 extends_documentation_fragment: awx.awx.auth
95 '''
96 
97 EXAMPLES = '''
98 '''
99 
100 RETURN = '''
101 id:
102     description: id of the newly launched command
103     returned: success
104     type: int
105     sample: 86
106 status:
107     description: status of newly launched command
108     returned: success
109     type: str
110     sample: pending
111 '''
112 
113 from ..module_utils.controller_api import ControllerAPIModule
114 
115 
116 def main():
117     # Any additional arguments that are not fields of the item can be added here
118     argument_spec = dict(
119         job_type=dict(choices=['run', 'check']),
120         inventory=dict(required=True),
121         limit=dict(),
122         credential=dict(required=True),
123         module_name=dict(required=True),
124         module_args=dict(),
125         forks=dict(type='int'),
126         verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]),
127         extra_vars=dict(type='dict'),
128         become_enabled=dict(type='bool'),
129         diff_mode=dict(type='bool'),
130         wait=dict(default=False, type='bool'),
131         interval=dict(default=2.0, type='float'),
132         timeout=dict(type='int'),
133         execution_environment=dict(),
134     )
135 
136     # Create a module for ourselves
137     module = ControllerAPIModule(argument_spec=argument_spec)
138 
139     # Extract our parameters
140     inventory = module.params.get('inventory')
141     credential = module.params.get('credential')
142     module_name = module.params.get('module_name')
143     module_args = module.params.get('module_args')
144 
145     wait = module.params.get('wait')
146     interval = module.params.get('interval')
147     timeout = module.params.get('timeout')
148 
149     # Create a datastructure to pass into our command launch
150     post_data = {
151         'module_name': module_name,
152         'module_args': module_args,
153     }
154     for arg in ['job_type', 'limit', 'forks', 'verbosity', 'extra_vars', 'become_enabled', 'diff_mode']:
155         if module.params.get(arg):
156             post_data[arg] = module.params.get(arg)
157 
158     # Attempt to look up the related items the user specified (these will fail the module if not found)
159     post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)
160     post_data['credential'] = module.resolve_name_to_id('credentials', credential)
161 
162     # Launch the ad hoc command
163     results = module.post_endpoint('ad_hoc_commands', **{'data': post_data})
164 
165     if results['status_code'] != 201:
166         module.fail_json(msg="Failed to launch command, see response for details", **{'response': results})
167 
168     if not wait:
169         module.exit_json(
170             **{
171                 'changed': True,
172                 'id': results['json']['id'],
173                 'status': results['json']['status'],
174             }
175         )
176 
177     # Invoke wait function
178     results = module.wait_on_url(url=results['json']['url'], object_name=module_name, object_type='Ad Hoc Command', timeout=timeout, interval=interval)
179 
180     module.exit_json(
181         **{
182             'changed': True,
183             'id': results['json']['id'],
184             'status': results['json']['status'],
185         }
186     )
187 
188 
189 if __name__ == '__main__':
190     main()
191
```
--- 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/awx_collection/plugins/modules/ad_hoc_command.py b/awx_collection/plugins/modules/ad_hoc_command.py
--- a/awx_collection/plugins/modules/ad_hoc_command.py
+++ b/awx_collection/plugins/modules/ad_hoc_command.py
@@ -145,6 +145,7 @@
     wait = module.params.get('wait')
     interval = module.params.get('interval')
     timeout = module.params.get('timeout')
+    execution_environment = module.params.get('execution_environment')
 
     # Create a datastructure to pass into our command launch
     post_data = {
@@ -158,6 +159,8 @@
     # Attempt to look up the related items the user specified (these will fail the module if not found)
     post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)
     post_data['credential'] = module.resolve_name_to_id('credentials', credential)
+    if execution_environment:
+        post_data['execution_environment'] = module.resolve_name_to_id('execution_environments', execution_environment)
 
     # Launch the ad hoc command
     results = module.post_endpoint('ad_hoc_commands', **{'data': post_data})

{"golden_diff": "diff --git a/awx_collection/plugins/modules/ad_hoc_command.py b/awx_collection/plugins/modules/ad_hoc_command.py\n--- a/awx_collection/plugins/modules/ad_hoc_command.py\n+++ b/awx_collection/plugins/modules/ad_hoc_command.py\n@@ -145,6 +145,7 @@\n     wait = module.params.get('wait')\n     interval = module.params.get('interval')\n     timeout = module.params.get('timeout')\n+    execution_environment = module.params.get('execution_environment')\n \n     # Create a datastructure to pass into our command launch\n     post_data = {\n@@ -158,6 +159,8 @@\n     # Attempt to look up the related items the user specified (these will fail the module if not found)\n     post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)\n     post_data['credential'] = module.resolve_name_to_id('credentials', credential)\n+    if execution_environment:\n+        post_data['execution_environment'] = module.resolve_name_to_id('execution_environments', execution_environment)\n \n     # Launch the ad hoc command\n     results = module.post_endpoint('ad_hoc_commands', **{'data': post_data})\n", "issue": "ad_hoc_command: execution_environment option is ignored\n### Please confirm the following\r\n\r\n- [X] I agree to follow this project's [code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html).\r\n- [X] I have checked the [current issues](https://github.com/ansible/awx/issues) for duplicates.\r\n- [X] I understand that AWX is open source software provided for free and that I might not receive a timely response.\r\n- [X] I am **NOT** reporting a (potential) security vulnerability. (These should be emailed to `security@ansible.com` instead.)\r\n\r\n### Bug Summary\r\n\r\nThe `execution_environment` option in `ad_hoc_command` module is ignored and runs with the default EE (`AWX EE (latest)`).\r\n\r\n\r\n\r\n### AWX version\r\n\r\n22.3.0\r\n\r\n### Select the relevant components\r\n\r\n- [ ] UI\r\n- [ ] UI (tech preview)\r\n- [ ] API\r\n- [ ] Docs\r\n- [X] Collection\r\n- [ ] CLI\r\n- [ ] Other\r\n\r\n### Installation method\r\n\r\nN/A\r\n\r\n### Modifications\r\n\r\nno\r\n\r\n### Ansible version\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\n_No response_\r\n\r\n### Web browser\r\n\r\n_No response_\r\n\r\n### Steps to reproduce\r\n\r\n\r\n\r\nRun with `execution_environment` option in the `awx.awx.ad_hoc_command` module. As in the following Playbook.\r\n\r\n```yaml\r\n    - name: Ad Hoc command test\r\n      awx.awx.ad_hoc_command:\r\n        inventory: Demo Inventory\r\n        credential: Demo Credential \r\n        module_name: command\r\n        module_args: echo I <3 Ansible\r\n        execution_environment: my_ee\r\n        wait: true\r\n````\r\n\r\n\r\n### Expected results\r\n\r\nRuns in the execution environment specified by the execution_environment option.\r\n\r\n\r\n### Actual results\r\n\r\nThe execution_environment option is ignored and runs with the default EE (`AWX EE (latest)`).\r\n\r\n### Additional information\r\n\r\n_No response_\n", "before_files": [{"content": "#!/usr/bin/python\n# coding: utf-8 -*-\n\n\n# (c) 2020, John Westcott IV <john.westcott.iv@redhat.com>\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n\n__metaclass__ = type\n\n\nANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}\n\nDOCUMENTATION = '''\n---\nmodule: ad_hoc_command\nauthor: \"John Westcott IV (@john-westcott-iv)\"\nversion_added: \"4.0.0\"\nshort_description: create, update, or destroy Automation Platform Controller ad hoc commands.\ndescription:\n    - Create, update, or destroy Automation Platform Controller ad hoc commands. See\n      U(https://www.ansible.com/tower) for an overview.\noptions:\n    job_type:\n      description:\n        - Job_type to use for the ad hoc command.\n      type: str\n      choices: [ 'run', 'check' ]\n    execution_environment:\n      description:\n        - Execution Environment to use for the ad hoc command.\n      required: False\n      type: str\n    inventory:\n      description:\n        - Inventory to use for the ad hoc command.\n      required: True\n      type: str\n    limit:\n      description:\n        - Limit to use for the ad hoc command.\n      type: str\n    credential:\n      description:\n        - Credential to use for ad hoc command.\n      required: True\n      type: str\n    module_name:\n      description:\n        - The Ansible module to execute.\n      required: True\n      type: str\n    module_args:\n      description:\n        - The arguments to pass to the module.\n      type: str\n    forks:\n      description:\n        - The number of forks to use for this ad hoc execution.\n      type: int\n    verbosity:\n      description:\n        - Verbosity level for this ad hoc command run\n      type: int\n      choices: [ 0, 1, 2, 3, 4, 5 ]\n    extra_vars:\n      description:\n        - Extra variables to use for the ad hoc command..\n      type: dict\n    become_enabled:\n      description:\n        - If the become flag should be set.\n      type: bool\n    diff_mode:\n      description:\n        - Show the changes made by Ansible tasks where supported\n      type: bool\n    wait:\n      description:\n        - Wait for the command to complete.\n      default: False\n      type: bool\n    interval:\n      description:\n        - The interval to request an update from the controller.\n      default: 2\n      type: float\n    timeout:\n      description:\n        - If waiting for the command to complete this will abort after this\n          amount of seconds\n      type: int\nextends_documentation_fragment: awx.awx.auth\n'''\n\nEXAMPLES = '''\n'''\n\nRETURN = '''\nid:\n    description: id of the newly launched command\n    returned: success\n    type: int\n    sample: 86\nstatus:\n    description: status of newly launched command\n    returned: success\n    type: str\n    sample: pending\n'''\n\nfrom ..module_utils.controller_api import ControllerAPIModule\n\n\ndef main():\n    # Any additional arguments that are not fields of the item can be added here\n    argument_spec = dict(\n        job_type=dict(choices=['run', 'check']),\n        inventory=dict(required=True),\n        limit=dict(),\n        credential=dict(required=True),\n        module_name=dict(required=True),\n        module_args=dict(),\n        forks=dict(type='int'),\n        verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]),\n        extra_vars=dict(type='dict'),\n        become_enabled=dict(type='bool'),\n        diff_mode=dict(type='bool'),\n        wait=dict(default=False, type='bool'),\n        interval=dict(default=2.0, type='float'),\n        timeout=dict(type='int'),\n        execution_environment=dict(),\n    )\n\n    # Create a module for ourselves\n    module = ControllerAPIModule(argument_spec=argument_spec)\n\n    # Extract our parameters\n    inventory = module.params.get('inventory')\n    credential = module.params.get('credential')\n    module_name = module.params.get('module_name')\n    module_args = module.params.get('module_args')\n\n    wait = module.params.get('wait')\n    interval = module.params.get('interval')\n    timeout = module.params.get('timeout')\n\n    # Create a datastructure to pass into our command launch\n    post_data = {\n        'module_name': module_name,\n        'module_args': module_args,\n    }\n    for arg in ['job_type', 'limit', 'forks', 'verbosity', 'extra_vars', 'become_enabled', 'diff_mode']:\n        if module.params.get(arg):\n            post_data[arg] = module.params.get(arg)\n\n    # Attempt to look up the related items the user specified (these will fail the module if not found)\n    post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)\n    post_data['credential'] = module.resolve_name_to_id('credentials', credential)\n\n    # Launch the ad hoc command\n    results = module.post_endpoint('ad_hoc_commands', **{'data': post_data})\n\n    if results['status_code'] != 201:\n        module.fail_json(msg=\"Failed to launch command, see response for details\", **{'response': results})\n\n    if not wait:\n        module.exit_json(\n            **{\n                'changed': True,\n                'id': results['json']['id'],\n                'status': results['json']['status'],\n            }\n        )\n\n    # Invoke wait function\n    results = module.wait_on_url(url=results['json']['url'], object_name=module_name, object_type='Ad Hoc Command', timeout=timeout, interval=interval)\n\n    module.exit_json(\n        **{\n            'changed': True,\n            'id': results['json']['id'],\n            'status': results['json']['status'],\n        }\n    )\n\n\nif __name__ == '__main__':\n    main()\n", "path": "awx_collection/plugins/modules/ad_hoc_command.py"}], "after_files": [{"content": "#!/usr/bin/python\n# coding: utf-8 -*-\n\n\n# (c) 2020, John Westcott IV <john.westcott.iv@redhat.com>\n# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)\n\nfrom __future__ import absolute_import, division, print_function\n\n__metaclass__ = type\n\n\nANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}\n\nDOCUMENTATION = '''\n---\nmodule: ad_hoc_command\nauthor: \"John Westcott IV (@john-westcott-iv)\"\nversion_added: \"4.0.0\"\nshort_description: create, update, or destroy Automation Platform Controller ad hoc commands.\ndescription:\n    - Create, update, or destroy Automation Platform Controller ad hoc commands. See\n      U(https://www.ansible.com/tower) for an overview.\noptions:\n    job_type:\n      description:\n        - Job_type to use for the ad hoc command.\n      type: str\n      choices: [ 'run', 'check' ]\n    execution_environment:\n      description:\n        - Execution Environment to use for the ad hoc command.\n      required: False\n      type: str\n    inventory:\n      description:\n        - Inventory to use for the ad hoc command.\n      required: True\n      type: str\n    limit:\n      description:\n        - Limit to use for the ad hoc command.\n      type: str\n    credential:\n      description:\n        - Credential to use for ad hoc command.\n      required: True\n      type: str\n    module_name:\n      description:\n        - The Ansible module to execute.\n      required: True\n      type: str\n    module_args:\n      description:\n        - The arguments to pass to the module.\n      type: str\n    forks:\n      description:\n        - The number of forks to use for this ad hoc execution.\n      type: int\n    verbosity:\n      description:\n        - Verbosity level for this ad hoc command run\n      type: int\n      choices: [ 0, 1, 2, 3, 4, 5 ]\n    extra_vars:\n      description:\n        - Extra variables to use for the ad hoc command..\n      type: dict\n    become_enabled:\n      description:\n        - If the become flag should be set.\n      type: bool\n    diff_mode:\n      description:\n        - Show the changes made by Ansible tasks where supported\n      type: bool\n    wait:\n      description:\n        - Wait for the command to complete.\n      default: False\n      type: bool\n    interval:\n      description:\n        - The interval to request an update from the controller.\n      default: 2\n      type: float\n    timeout:\n      description:\n        - If waiting for the command to complete this will abort after this\n          amount of seconds\n      type: int\nextends_documentation_fragment: awx.awx.auth\n'''\n\nEXAMPLES = '''\n'''\n\nRETURN = '''\nid:\n    description: id of the newly launched command\n    returned: success\n    type: int\n    sample: 86\nstatus:\n    description: status of newly launched command\n    returned: success\n    type: str\n    sample: pending\n'''\n\nfrom ..module_utils.controller_api import ControllerAPIModule\n\n\ndef main():\n    # Any additional arguments that are not fields of the item can be added here\n    argument_spec = dict(\n        job_type=dict(choices=['run', 'check']),\n        inventory=dict(required=True),\n        limit=dict(),\n        credential=dict(required=True),\n        module_name=dict(required=True),\n        module_args=dict(),\n        forks=dict(type='int'),\n        verbosity=dict(type='int', choices=[0, 1, 2, 3, 4, 5]),\n        extra_vars=dict(type='dict'),\n        become_enabled=dict(type='bool'),\n        diff_mode=dict(type='bool'),\n        wait=dict(default=False, type='bool'),\n        interval=dict(default=2.0, type='float'),\n        timeout=dict(type='int'),\n        execution_environment=dict(),\n    )\n\n    # Create a module for ourselves\n    module = ControllerAPIModule(argument_spec=argument_spec)\n\n    # Extract our parameters\n    inventory = module.params.get('inventory')\n    credential = module.params.get('credential')\n    module_name = module.params.get('module_name')\n    module_args = module.params.get('module_args')\n\n    wait = module.params.get('wait')\n    interval = module.params.get('interval')\n    timeout = module.params.get('timeout')\n    execution_environment = module.params.get('execution_environment')\n\n    # Create a datastructure to pass into our command launch\n    post_data = {\n        'module_name': module_name,\n        'module_args': module_args,\n    }\n    for arg in ['job_type', 'limit', 'forks', 'verbosity', 'extra_vars', 'become_enabled', 'diff_mode']:\n        if module.params.get(arg):\n            post_data[arg] = module.params.get(arg)\n\n    # Attempt to look up the related items the user specified (these will fail the module if not found)\n    post_data['inventory'] = module.resolve_name_to_id('inventories', inventory)\n    post_data['credential'] = module.resolve_name_to_id('credentials', credential)\n    if execution_environment:\n        post_data['execution_environment'] = module.resolve_name_to_id('execution_environments', execution_environment)\n\n    # Launch the ad hoc command\n    results = module.post_endpoint('ad_hoc_commands', **{'data': post_data})\n\n    if results['status_code'] != 201:\n        module.fail_json(msg=\"Failed to launch command, see response for details\", **{'response': results})\n\n    if not wait:\n        module.exit_json(\n            **{\n                'changed': True,\n                'id': results['json']['id'],\n                'status': results['json']['status'],\n            }\n        )\n\n    # Invoke wait function\n    results = module.wait_on_url(url=results['json']['url'], object_name=module_name, object_type='Ad Hoc Command', timeout=timeout, interval=interval)\n\n    module.exit_json(\n        **{\n            'changed': True,\n            'id': results['json']['id'],\n            'status': results['json']['status'],\n        }\n    )\n\n\nif __name__ == '__main__':\n    main()\n", "path": "awx_collection/plugins/modules/ad_hoc_command.py"}]}