Salt: `import_yaml` does not work in pillar sls files

Here is how to reproduce the problem:

  • Execute this to create user directories:
# qubesctl state.sls qubes.user-dirs
  • Create file: /srv/user_pillar/top.sls:
user:
  '*':
    - source
    - depend
  • Create file: /srv/user_pillar/source.sls:
source:
  value: 5
  • Create file: /srv/user_pillar/depend.sls:
{% import_yaml "source.sls" as source %}

depend:
  value: {{ source['source']['value'] + 1 }}
  • Create file: /srv/user_salt/atest.sls:
{% set value = salt['pillar.get']('depend:value', 0) %}

message:
  test.configurable_test_state:
    - changes: False
    - comment: 'value: "{{ value }}"'
  • Execute the atest.sls state file:
# qubesctl --show-output state.sls atest saltenv=user

Here is the expected result:

local:
----------
          ID: message
    Function: test.configurable_test_state
      Result: True
     Comment: value: "6"
     Started: 02:53:08.493550
    Duration: 0.489 ms
     Changes:

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:   0.489 ms

Here is the actual result:

[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.chroot. Module will not be loaded: 'path.which'
[WARNING ] salt.loaded.int.module.chroot.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'chroot', please fix this.
[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.rebootmgr. Module will not be loaded: 'path.which'
[WARNING ] salt.loaded.int.module.rebootmgr.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'rebootmgr', please fix this.
[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.rh_service. Module will not be loaded: 'systemd.booted'
[WARNING ] salt.loaded.int.module.rh_service.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'rh_service', please fix this.
[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.transactional_update. Module will not be loaded: 'path.which'
[WARNING ] salt.loaded.int.module.transactional_update.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'transactional_update', please fix this.
[ERROR   ] Exception raised when processing __virtual__ function for salt.loaded.int.module.win_timezone. Module will not be loaded: 'platform.is_windows'
[WARNING ] salt.loaded.int.module.win_timezone.__virtual__() is wrongly returning `None`. It should either return `True`, `False` or a new name. If you're the developer of the module 'win_timezone', please fix this.
[ERROR   ] Rendering exception occurred
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 476, in render_jinja_tmpl
    output = template.render(**decoded_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 161, in get_source
    self.check_cache(_template)
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 115, in check_cache
    ret = self.cache_file(template)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 107, in cache_file
    fcl = self.file_client()
          ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 96, in file_client
    self._file_client = salt.fileclient.get_file_client(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/fileclient.py", line 60, in get_file_client
    return {"remote": RemoteClient, "local": FSClient, "pillar": PillarClient}.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/fileclient.py", line 92, in __init__
    self.utils = salt.loader.utils(self.opts)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/__init__.py", line 536, in utils
    return LazyLoader(
           ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 262, in __init__
    opts = copy.deepcopy(opts)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/context.py", line 234, in __deepcopy__
    copy.deepcopy(self.__dict, memo), copy.deepcopy(self.pre_keys, memo)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/context.py", line 139, in __deepcopy__
    new_obj.global_data = copy.deepcopy(self.global_data, memo)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 161, in deepcopy
    rv = reductor(4)
         ^^^^^^^^^^^
TypeError: cannot pickle '_thread.RLock' object

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 218, in render_tmpl
    output = render_str(tmplstr, context, tmplpath)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 522, in render_jinja_tmpl
    raise SaltRenderError(
salt.exceptions.SaltRenderError: Jinja error: cannot pickle '_thread.RLock' object
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 476, in render_jinja_tmpl
    output = template.render(**decoded_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 161, in get_source
    self.check_cache(_template)
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 115, in check_cache
    ret = self.cache_file(template)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 107, in cache_file
    fcl = self.file_client()
          ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 96, in file_client
    self._file_client = salt.fileclient.get_file_client(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/fileclient.py", line 60, in get_file_client
    return {"remote": RemoteClient, "local": FSClient, "pillar": PillarClient}.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/fileclient.py", line 92, in __init__
    self.utils = salt.loader.utils(self.opts)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/__init__.py", line 536, in utils
    return LazyLoader(
           ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 262, in __init__
    opts = copy.deepcopy(opts)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/context.py", line 234, in __deepcopy__
    copy.deepcopy(self.__dict, memo), copy.deepcopy(self.pre_keys, memo)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/context.py", line 139, in __deepcopy__
    new_obj.global_data = copy.deepcopy(self.global_data, memo)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 161, in deepcopy
    rv = reductor(4)
         ^^^^^^^^^^^
TypeError: cannot pickle '_thread.RLock' object

; line 1

---
{% import_yaml "source.sls" as source %}    <======================

depend:
  value: {{ source['source']['value'] + 1 }}

Traceback (most recent call last):
[...]
---
[CRITICAL] Rendering SLS 'depend' failed, render error:
Jinja error: cannot pickle '_thread.RLock' object

...

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/salt/pillar/__init__.py", line 938, in render_pstate
    state = compile_template(
            ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/template.py", line 99, in compile_template
    ret = render(input_data, saltenv, sls, **render_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 159, in __call__
    ret = self.loader.run(run_func, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1245, in run
    return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 1260, in _run_as
    return _func_or_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/renderers/jinja.py", line 62, in render
    tmp_data = salt.utils.templates.JINJA(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 218, in render_tmpl
    output = render_str(tmplstr, context, tmplpath)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 522, in render_jinja_tmpl
    raise SaltRenderError(
salt.exceptions.SaltRenderError: Jinja error: cannot pickle '_thread.RLock' object
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/salt/utils/templates.py", line 476, in render_jinja_tmpl
    output = template.render(**decoded_context)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/usr/lib/python3.11/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 161, in get_source
    self.check_cache(_template)
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 115, in check_cache
    ret = self.cache_file(template)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 107, in cache_file
    fcl = self.file_client()
          ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/jinja.py", line 96, in file_client
    self._file_client = salt.fileclient.get_file_client(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/fileclient.py", line 60, in get_file_client
    return {"remote": RemoteClient, "local": FSClient, "pillar": PillarClient}.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/fileclient.py", line 92, in __init__
    self.utils = salt.loader.utils(self.opts)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/__init__.py", line 536, in utils
    return LazyLoader(
           ^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/loader/lazy.py", line 262, in __init__
    opts = copy.deepcopy(opts)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/context.py", line 234, in __deepcopy__
    copy.deepcopy(self.__dict, memo), copy.deepcopy(self.pre_keys, memo)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 153, in deepcopy
    y = copier(memo)
        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/salt/utils/context.py", line 139, in __deepcopy__
    new_obj.global_data = copy.deepcopy(self.global_data, memo)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.11/copy.py", line 161, in deepcopy
    rv = reductor(4)
         ^^^^^^^^^^^
TypeError: cannot pickle '_thread.RLock' object

; line 1

---
{% import_yaml "source.sls" as source %}    <======================

depend:
  value: {{ source['source']['value'] + 1 }}

Traceback (most recent call last):
[...]
---
[CRITICAL] Pillar render error: Rendering SLS 'depend' failed. Please see master log for details.
local:
    Data failed to compile:
----------
    Pillar failed to render with the following messages:
----------
    Rendering SLS 'depend' failed. Please see master log for details.
DOM0 configuration failed, not continuing

Here is the system setup:

  • Qubes OS version: 4.2
  • Python version: 3.11.6-1.fc37
  • Packages:
$ sudo dnf -C list installed | grep salt
qubes-mgmt-salt.noarch                         4.2.2-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-admin-tools.noarch             4.2.2-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-base.noarch                    4.1.7-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-base-config.noarch             4.1.2-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-base-topd.noarch               4.2.1-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-config.noarch                  4.2.2-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-dom0.noarch                    4.2.2-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-dom0-qvm.noarch                4.2.1-1.fc37                      @qubes-dom0-cached
qubes-mgmt-salt-dom0-update.noarch             4.1.14-1.fc37                     @qubes-dom0-cached
qubes-mgmt-salt-dom0-virtual-machines.noarch   4.2.14-1.fc37                     @qubes-dom0-cached
salt.noarch                                    3006.5-1.fc37                     @qubes-dom0-cached
salt-minion.noarch                             3006.5-1.fc37                     @qubes-dom0-cached

I also tested in an ArchLinux standalone HVM using plain salt-call --local. It worked.

Here is the Arch Linux system setup:

  • Arch Linux install version: 2024.07.01
  • Salt version: 3007.0-2
  • Python version: 3.12.4-1

I also tested in a Fedora 39 dispvm. It worked.

Here is the Fedora 39 dispvm setup:

  • Packages:
$ sudo dnf -C list installed | grep salt
qubes-mgmt-salt-vm-connector.noarch            4.2.2-1.fc39                        @qubes-vm-r4.2-current                         
salt.noarch                                    3006.8-1.fc39                       @updates                                       
salt-minion.noarch                             3006.8-1.fc39                       @updates                                       
salt-ssh.noarch                                3006.8-1.fc39                       @updates
  • Python version: 3.12.3-2.fc39

Question:

  • How can I make import_yaml work in Qubes OS?
  • Is this an upstream problem that might get fixed when Qubes OS upgrades?