When using zos_job_submit in a role a mapping proxy error occurs. The goal here is to use use_template in zos_job_submit passing a data set to the template via variable, the JCL is simple it just does a LISTCAT, it can be any data set but the playbook includes one.
Error:
"Unexpected failure during module execution: cannot pickle 'mappingproxy' object",
Playbook: playbooks/zos_job_submit_loop.yml
---
- hosts: zvm
collections:
- ibm.ibm_zos_core
gather_facts: false
vars:
dataset_list:
- dataset_name : "SYS1.PROCLIB"
environment: "{{ environment_vars }}"
tasks:
# Test role
- name: sumit JCL in a role with loop
vars:
dataset_name: "{{ item.dataset_name }}"
include_role:
name: jcl_test_role
loop: "{{ dataset_list }}"
The template: playbooks/roles/jcl_test_role/templates/listc_template.jcl
I assume that the serialization from the deep copy's pickling is failing. This relates to issue #1251 , its possible this issue could be resolved with #1251 but note when testing version 1.7.0, although no deep copy error occurred the template variable was not inserted into the JCL , I will open another issue for that.
IBM z/OS Ansible core Version
v1.9.0
IBM Z Open Automation Utilities
v1.2.5 (default)
IBM Enterprise Python
v3.10.x
ansible-version
v2.16.x (default)
z/OS version
v2.5 (default)
Ansible module
zos_job_submit
Playbook verbosity output.
The full traceback is:
Traceback (most recent call last):
File "/Users/ddimatos/git/gh/ibm_zos_core/venv/venv-2.16/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 165, in run
res = self._execute()
^^^^^^^^^^^^^^^
File "/Users/ddimatos/git/gh/ibm_zos_core/venv/venv-2.16/lib/python3.12/site-packages/ansible/executor/task_executor.py", line 637, in _execute
result = self._handler.run(task_vars=vars_copy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/ddimatos/.ansible/collections/ansible_collections/ibm/ibm_zos_core/plugins/action/zos_job_submit.py", line 154, in run
copy_task = copy.deepcopy(self._task)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 162, in deepcopy
y = _reconstruct(x, memo, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 259, in _reconstruct
state = deepcopy(state, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 221, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 162, in deepcopy
y = _reconstruct(x, memo, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 259, in _reconstruct
state = deepcopy(state, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 221, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 162, in deepcopy
y = _reconstruct(x, memo, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 259, in _reconstruct
state = deepcopy(state, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 221, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 221, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 196, in _deepcopy_list
append(deepcopy(a, memo))
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 162, in deepcopy
y = _reconstruct(x, memo, *rv)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 259, in _reconstruct
state = deepcopy(state, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 136, in deepcopy
y = copier(x, memo)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 221, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.0/Frameworks/Python.framework/Versions/3.12/lib/python3.12/copy.py", line 151, in deepcopy
rv = reductor(4)
^^^^^^^^^^^
TypeError: cannot pickle 'mappingproxy' object
fatal: [zvm]: FAILED! => {
"msg": "Unexpected failure during module execution: cannot pickle 'mappingproxy' object",
"stdout": ""
}
Is there an existing issue for this?
Bug description
When using zos_job_submit in a role a mapping proxy error occurs. The goal here is to use
use_template
inzos_job_submit
passing a data set to the template via variable, the JCL is simple it just does a LISTCAT, it can be any data set but the playbook includes one.Error:
Playbook:
playbooks/zos_job_submit_loop.yml
The template:
playbooks/roles/jcl_test_role/templates/listc_template.jcl
The role:
playbooks/roles/jcl_test_role/tasks/main.yml
To create a role:
mkdir roles
cd roles/
ansible-galaxy init jcl_test_role
Then add the contents of the role (above) tojcl_test_role/tasks/main.yml
I also tried this with IBM z/OS Core 1.7.0 when use of deep copy was not used copy_task = copy.deepcopy(self._task).
I assume that the serialization from the deep copy's pickling is failing. This relates to issue #1251 , its possible this issue could be resolved with #1251 but note when testing version 1.7.0, although no deep copy error occurred the template variable was not inserted into the JCL , I will open another issue for that.
IBM z/OS Ansible core Version
v1.9.0
IBM Z Open Automation Utilities
v1.2.5 (default)
IBM Enterprise Python
v3.10.x
ansible-version
v2.16.x (default)
z/OS version
v2.5 (default)
Ansible module
zos_job_submit
Playbook verbosity output.
Ansible configuration.
No response
Contents of the inventory
No response
Contents of
group_vars
orhost_vars
No response