saltstack / salt-bootstrap

Generic Salt Bootstrap Script
Other
929 stars 549 forks source link

salt-bootstrap not working since jinja release #1810

Open jpic opened 2 years ago

jpic commented 2 years ago

Currently, salt-bootstrap fails to install a working saltstack because it does pip install -U of the requirements, which upgrades jinja to the latest release which does not have expected imports by salt.

https://github.com/saltstack/salt/issues/61848

Ch3LL commented 2 years ago

Can you clarify how you are running the bootstrap script? And yes that might be the answer, will need to dig a bit further once I know the type of bootstrap install your doing.

dgutman commented 2 years ago

Is there an easy workaround? I actually had another one of my flask apps break for the same issue..

I just installed (or tried to) salt-master 3004 from the main repo, and as soon as I try and run salt-key , it's also throwing another similar error: Error: module 'jinja2' has no attribute 'contextfunction'

deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg arch=amd64] https://repo.saltproject.io/py3/ubuntu/20.04/amd64/latest focal main

jpic commented 2 years ago

I believe it's failing for everyone installing any version of salt that didn't pin jinja2 because the bootstrap script installs with pip install -U: https://github.com/saltstack/salt-bootstrap/blob/develop/bootstrap-salt.sh#L2674 which pulls an incompatible jinja.

People using packages install are not affected: https://github.com/saltstack/salt-bootstrap/blob/develop/bootstrap-salt.sh#L3096

Workaround is something like:

curl -L https://bootstrap.saltstack.com | sh -s -- -x python3 [your args...] -g https://github.com/jpic/salt git jinjabackport

Where https://github.com/jpic/salt is your fork where you backported the hotfix from saltstack/salt#61850 in a new branch called jinjabackport.

Good luck everyone!

jpic commented 2 years ago

@Ch3LL

curl -L https://bootstrap.saltstack.com | sh -s -- -x python3 -M git v3002.2

Fails with:

Created symlink /etc/systemd/system/multi-user.target.wants/salt-minion.service → /lib/systemd/system/salt-minion.service.
 *  INFO: Running install_ubuntu_check_services()
 *  INFO: Running install_ubuntu_restart_daemons()
Job for salt-master.service failed because the control process exited with error code.
See "systemctl status salt-master.service" and "journalctl -xe" for details.
 * ERROR: No init.d support for salt-master was found
 * ERROR: Failed to run install_ubuntu_restart_daemons()!!!

journal:

lines 1-27/27 (END)
-- Logs begin at Wed 2022-03-30 14:23:29 UTC, end at Wed 2022-03-30 14:29:44 UTC. --
Mar 30 14:29:43 ubuntu-2004 systemd[1]: Starting The Salt Master Server...
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]: Traceback (most recent call last):
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/bin/salt-master", line 8, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     sys.exit(salt_master())
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/scripts.py", line 95, in salt_master
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.cli.daemons
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/cli/daemons.py", line 53, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.utils.parsers
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/utils/parsers.py", line 24, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.config as config
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/config/__init__.py", line 103, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     _DFLT_IPC_WBUFFER = _gather_buffer_space() * 0.5
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/config/__init__.py", line 91, in _gather_buffer_space
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.grains.core
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/grains/core.py", line 31, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.modules.cmdmod
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/modules/cmdmod.py", line 31, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.utils.templates
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/utils/templates.py", line 19, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     import salt.utils.jinja
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:   File "/usr/local/lib/python3.8/dist-packages/salt/utils/jinja.py", line 28, in <module>
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]:     from jinja2 import BaseLoader, Markup, TemplateNotFound, nodes
Mar 30 14:29:44 ubuntu-2004 salt-master[7796]: ImportError: cannot import name 'Markup' from 'jinja2' (/usr/local/lib/python3.8/dist-packages/jinja2/__init__.py)
Mar 30 14:29:44 ubuntu-2004 systemd[1]: salt-master.service: Main process exited, code=exited, status=1/FAILURE
Mar 30 14:29:44 ubuntu-2004 systemd[1]: salt-master.service: Failed with result 'exit-code'.
Mar 30 14:29:44 ubuntu-2004 systemd[1]: Failed to start The Salt Master Server.

Jinja maintainer recommendation: version pinning

dmurphy18 commented 4 months ago

@jpic Can you check if this is still an issue with the just released 2024-07-16, which contains a major clean up of the script. If no longer a problem, please consider closing this issue.

dmurphy18 commented 4 months ago

whoops