Last active
July 27, 2025 19:26
-
-
Save Ruchip16/2121f10a5100cbcffef7cb1f55efe54f to your computer and use it in GitHub Desktop.
Reproducing Ansible-core 2.19 direct execution bug (ActionBase._parse_returned_data missing profile)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Reproduce Ansible-core 2.19 direct-exec error | |
hosts: ios | |
gather_facts: false | |
vars: | |
ansible_connection: ansible.netcommon.network_cli | |
ansible_network_os: cisco.ios.ios | |
ansible_become_method: enable | |
import_modules: true # triggers direct execution mode | |
tasks: | |
- name: Run command module | |
cisco.ios.ios_command: | |
commands: | |
- show run | i hostname | |
register: output | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ansible-playbook [core 2.19.0.dev0] (devel 3b66150cc3) last updated 2025/05/28 15:37:10 (GMT +550) | |
config file = None | |
configured module search path = ['/home/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] | |
ansible python module location = /path/to/ansible/lib/ansible | |
ansible collection location = /home/username/.ansible/collections:/usr/share/ansible/collections | |
executable location = /home/username/.virtualenvs/testenv/bin/ansible-playbook | |
python version = 3.13.2 (main, Feb 4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)] (/home/username/.virtualenvs/testenv/bin/python) | |
jinja version = 3.1.5 | |
pyyaml version = 6.0.2 (with libyaml v0.2.5) | |
No config file found; using defaults | |
setting up inventory plugins | |
Loading collection ansible.builtin from | |
host_list declined parsing /path/to/inventory/ios_inventory as it did not pass its verify_file() method | |
script declined parsing /path/to/inventory/ios_inventory as it did not pass its verify_file() method | |
auto declined parsing /path/to/inventory/ios_inventory as it did not pass its verify_file() method | |
Parsed /path/to/inventory/ios_inventory inventory source with ini plugin | |
Loading collection cisco.ios from /path/to/collections/cisco/ios | |
Loading callback plugin default of type stdout, v2.0 from /path/to/ansible/plugins/callback/default.py | |
Skipping callback 'default', as we already have a stdout callback. | |
Skipping callback 'minimal', as we already have a stdout callback. | |
Skipping callback 'oneline', as we already have a stdout callback. | |
PLAYBOOK: ios_netcommon.yaml *************************************************** | |
Positional arguments: ios_netcommon.yaml | |
verbosity: 4 | |
connection: ssh | |
become_method: sudo | |
tags: ('all',) | |
inventory: ('/path/to/inventory/ios_inventory',) | |
forks: 5 | |
1 plays in ios_netcommon.yaml | |
PLAY [Reproduce Ansible-core 2.19 direct-exec error] *************************** | |
TASK [Run command module] ****************************************************** | |
task path: /path/to/ios_netcommon.yaml:11 | |
Loading collection ansible.netcommon from /path/to/collections/ansible/netcommon | |
Loading collection ansible.utils from /path/to/collections/ansible/utils | |
<ios_device> Using network group action cisco.ios.ios for cisco.ios.ios_command | |
<ios_device> attempting to start connection | |
<ios_device> using connection plugin ansible.netcommon.network_cli | |
<ios_device> local domain socket does not exist, starting it | |
<ios_device> control socket path is /home/username/.ansible/pc/99ff65cbe2 | |
<ios_device> Loading collection ansible.builtin from | |
<ios_device> Loading collection ansible.netcommon from /path/to/collections/ansible/netcommon | |
<ios_device> Loading collection ansible.utils from /path/to/collections/ansible/utils | |
<ios_device> Loading collection cisco.ios from /path/to/collections/cisco/ios | |
<ios_device> local domain socket listeners started successfully | |
<ios_device> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /path/to/collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios | |
<ios_device> ssh type is set to libssh | |
<ios_device> Loading collection ansible.builtin from | |
<ios_device> local domain socket path is /home/username/.ansible/pc/99ff65cbe2 | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: enabled | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_command at /path/to/collections/cisco/ios/plugins/modules/ios_command.py | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_command | |
[ERROR]: Task failed: ActionBase._parse_returned_data() missing 1 required positional argument: 'profile' | |
Origin: /path/to/ios_netcommon.yaml:11:7 | |
9 import_modules: true # triggers direct execution mode | |
10 tasks: | |
11 - name: Run command module | |
^ column 7 | |
fatal: [ios_device]: FAILED! => { | |
"changed": false, | |
"msg": "Task failed: ActionBase._parse_returned_data() missing 1 required positional argument: 'profile'" | |
} | |
PLAY RECAP ********************************************************************* | |
ios_device : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAYBOOK: ios_netcommon.yaml *************************************************************************************** | |
Positional arguments: ios_netcommon.yaml | |
verbosity: 4 | |
connection: ssh | |
become_method: sudo | |
tags: ('all',) | |
inventory: ('inv/ios_inventory',) | |
forks: 5 | |
1 plays in ios_netcommon.yaml | |
PLAY [Reproduce Ansible-core 2.19 direct-exec error] *************************************************************** | |
TASK [Run command module] ****************************************************************************************** | |
task path: ios_netcommon.yaml:11 | |
Loading collection ansible.netcommon from <path>/ansible_collections/ansible/netcommon | |
Loading collection ansible.utils from <path>/ansible_collections/ansible/utils | |
<ios_device> Using network group action cisco.ios.ios for cisco.ios.ios_command | |
<ios_device> attempting to start connection | |
<ios_device> using connection plugin ansible.netcommon.network_cli | |
<ios_device> local domain socket does not exist, starting it | |
<ios_device> control socket path is <path>/.ansible/pc/<hash> | |
<ios_device> Loading collection ansible.builtin from | |
<ios_device> Loading collection cisco.ios from <path>/ansible_collections/cisco/ios | |
<ios_device> local domain socket listeners started successfully | |
<ios_device> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path <path>/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios | |
<ios_device> ssh type is set to libssh | |
<ios_device> local domain socket path is <path>/.ansible/pc/<hash> | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: enabled | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_command at <path>/ansible_collections/cisco/ios/plugins/modules/ios_command.py | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_command | |
<ios_device> ANSIBLE_NETWORK_IMPORT_MODULES: complete | |
[WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg. | |
[DEPRECATION WARNING]: Passing `warnings` to `exit_json` or `fail_json` is deprecated. This feature will be removed from ansible-core version 2.23. Use `AnsibleModule.warn` instead. | |
[ERROR]: Task failed: Action failed: Module result deserialization failed: No start of json char found | |
Task failed: Action failed. | |
Origin: ios_netcommon.yaml:11:7 | |
<<< caused by >>> | |
Module result deserialization failed: No start of json char found See stdout/stderr for the returned output. | |
fatal: [ios_device]: FAILED! => { | |
"changed": false, | |
"module_stderr": "Unknown profile name 'module_None_m2c'.", | |
"module_stdout": "", | |
"msg": "Module result deserialization failed: No start of json char found" | |
} | |
PLAY RECAP ********************************************************************************************************* | |
ios_device : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Objective:
To reproduce and isolate two key issues introduced in ansible-core 2.19.x when using direct execution (import_modules: true) with networking modules (e.g., cisco.ios.ios_command).
❗ Error 1: TypeError:
_parse_returned_data() missing 1 required positional argument: 'profile'
When does it occur?
ActionModule._parse_returned_data()
.data = self._parse_returned_data(dict_out) # missing 'profile'
https://github.com/ansible-collections/ansible.netcommon/blob/main/plugins/action/network.py#L341
❗ Error 2: Module result deserialization failed:
No start of json char found
After patching _parse_returned_data() or attempting workarounds, this error pops up as a side effect, indicating the module output was not valid JSON or deserialization failed.
https://github.com/ansible-collections/ansible.netcommon/blob/main/plugins/action/network.py#L283
This likely stems from the patched AnsibleModule not initializing profile correctly in direct execution mode, or an incompatibility in module output format when bypassing standard AnsibleModule init.