diff --git a/pillar/kingfisher_main.sls b/pillar/kingfisher_main.sls index 80343814..7e4ffe43 100644 --- a/pillar/kingfisher_main.sls +++ b/pillar/kingfisher_main.sls @@ -162,6 +162,9 @@ docker: uid: 1005 syslog_logging: True +python: + version: '3.13' + kingfisher_collect: user: collect group: deployer diff --git a/salt/lib.sls b/salt/lib.sls index 4e68e947..8e7213e6 100644 --- a/salt/lib.sls +++ b/salt/lib.sls @@ -97,6 +97,18 @@ unset {{ setting_name }} in {{ filename }}: # Bug: The "user" parameter is ignored, unless the undocumented "runas" parameter is used. # https://github.com/saltstack/salt/issues/59088#issuecomment-912148651 {% macro virtualenv(directory, user, parent_directory, requirements_file, watch_in=None) %} +{% if salt['pillar.get']('python:version') %} +# If the Python version changes, remove the virtual environment, so that it is recreated. +{{ directory }}-virtualenv-clear: + file.absent: + - name: {{ directory }}/.ve + - onchanges: + - pkg: python + - require_in: + - virtualenv: {{ directory }}-virtualenv + - virtualenv: {{ directory }}-uv +{% endif %} + {{ directory }}-virtualenv: virtualenv.managed: - name: {{ directory }}/.ve @@ -104,13 +116,8 @@ unset {{ setting_name }} in {{ filename }}: - runas: {{ user }} - user: {{ user }} - require: {{ ([{'pkg': 'virtualenv'}] + [parent_directory])|yaml }} -{% if salt['pillar.get']('python:version') %} - # If the Python version changes, reinstall the virtual environment. - - watch: - - pkg: python -{% endif %} -# This state only differs from the *-virtualenv state by installing uv and not watching python. +# This state only differs from the *-virtualenv state by installing uv. {{ directory }}-uv: virtualenv.managed: - name: {{ directory }}/.ve diff --git a/salt/python/init.sls b/salt/python/init.sls index 993fcacd..3e980184 100644 --- a/salt/python/init.sls +++ b/salt/python/init.sls @@ -5,8 +5,6 @@ python: pkg.installed: - pkgs: - python{{ pillar.python.version }} - # Avoid "ModuleNotFoundError: No module named 'distutils.command'". - - python{{ pillar.python.version }}-distutils - require: - pkgrepo: python {% endif %}