Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra_vars bug in ansible.controller.ad_hoc_command #14585

Merged
merged 6 commits into from
Oct 25, 2023

Conversation

jessicamack
Copy link
Member

SUMMARY

Related #14481
We're currently submitting an OrderedDict to a CharField which is throwing a validation error on the serializer.
This PR converts the OrderedDict to a JSON string before submitting it.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • API
AWX VERSION
awx: 23.2.1.dev20+gcec6e1e93a.d20231018
ADDITIONAL INFORMATION

Before

PLAY [all] ************************************************************************************************************
TASK [Launch an ad hoc command] ***************************************************************************************
[WARNING]: You are running collection version 22.7.0 but connecting to AWX version 23.1.1.dev1+g8feeb5f1fa
fatal: [localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "Failed to launch command, see response for details", "response": {"json": {"extra_vars": ["Not a valid string."]}, "status_code": 400}}
PLAY RECAP ************************************************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0 

After

PLAY [all] ************************************************************************************************************
TASK [Launch an ad hoc command] ***************************************************************************************
[WARNING]: You are running collection version 22.7.0 but connecting to AWX version 23.1.1.dev1+g8feeb5f1fa
changed: [localhost] => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": true, "id": 76, "status": "new"}
PLAY RECAP ************************************************************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    

@github-actions github-actions bot added the component:awx_collection issues related to the collection for controlling AWX label Oct 19, 2023
Signed-off-by: jessicamack <[email protected]>
@TheRealHaoLiu
Copy link
Member

TASK [ad_hoc_command : Launch an Ad Hoc Command with extra_vars] ***************
task path: /home/runner/.ansible/collections/ansible_collections/awx/awx/tests/output/.tmp/integration/ad_hoc_command-0s_7_o2t-ÅÑŚÌβŁÈ/tests/integration/targets/ad_hoc_command/tasks/main.yml:75
Using module file /home/runner/.ansible/collections/ansible_collections/awx/awx/plugins/modules/ad_hoc_command.py
Pipelining is enabled.
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: runner
<testhost> EXEC /bin/sh -c '/usr/bin/python3 && sleep 0'
changed: [testhost] => {
    "changed": true,
    "id": 3,
    "invocation": {
        "module_args": {
            "become_enabled": null,
            "controller_config_file": null,
            "controller_host": null,
            "controller_oauthtoken": null,
            "controller_password": null,
            "controller_username": null,
            "credential": "AWX-Collection-tests-ad_hoc_command-ssh-cred-UiZvdOKfOepLHwLS",
            "diff_mode": null,
            "execution_environment": null,
            "extra_vars": {
                "var1": "test var"
            },
            "forks": null,
            "interval": 2.0,
            "inventory": "Demo Inventory",
            "job_type": null,
            "limit": null,
            "module_args": null,
            "module_name": "ping",
            "request_timeout": null,
            "timeout": null,
            "validate_certs": null,
            "verbosity": null,
            "wait": true
        }
    },
    "status": "successful"
}

TASK [ad_hoc_command : assert] *************************************************
task path: /home/runner/.ansible/collections/ansible_collections/awx/awx/tests/output/.tmp/integration/ad_hoc_command-0s_7_o2t-ÅÑŚÌβŁÈ/tests/integration/targets/ad_hoc_command/tasks/main.yml:85
ok: [testhost] => {
    "changed": false,
    "msg": "All assertions passed"
}

confirmed that the new test is being ran in the CI and passes

@jessicamack jessicamack merged commit 44255f3 into ansible:devel Oct 25, 2023
20 checks passed
djyasin pushed a commit to djyasin/awx that referenced this pull request Sep 16, 2024
* convert to valid type for serializer

* check that extra_vars are in request

* remove doubled line

* add integration test for change

* move change to the ad_hoc_command module

Signed-off-by: jessicamack <[email protected]>

* fix imports

Signed-off-by: jessicamack <[email protected]>

---------

Signed-off-by: jessicamack <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:awx_collection issues related to the collection for controlling AWX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"extra_vars": ["Not a valid string."] in ansible.controller.ad_hoc_command
3 participants