Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No way to debug templates over salt-ssh #50196

Open
max-arnold opened this issue Oct 24, 2018 · 9 comments · Fixed by #65517
Open

No way to debug templates over salt-ssh #50196

max-arnold opened this issue Oct 24, 2018 · 9 comments · Fixed by #65517
Assignees
Labels
Bug broken, incorrect, or confusing behavior Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
Milestone

Comments

@max-arnold
Copy link
Contributor

Description of Issue/Question

The recommended ways to debug templates are (as seen in the Slack chat):

salt 'example.com' slsutil.renderer /path/to/file.jinja 'jinja'
salt 'example.com' cp.get_template salt://path/to/template /dev/stdout template=jinja

Unfortunately, I was unable to make it work over salt-ssh:

salt-ssh -l debug example.com slsutil.renderer path='salt://test.sls' default_renderer='jinja'
...
[DEBUG   ] Could not LazyLoad slsutil.renderer: 'slsutil.renderer' is not available.
...
salt-ssh example.com cp.get_template salt://test.sls /dev/stdout template=jinja

example.com:
    ----------
    retcode:
        0
    stderr:
        Traceback (most recent call last):
          File "/var/tmp/.root_7e26e1_salt/salt-call", line 15, in <module>
            salt_call()
          File "/var/tmp/.root_7e26e1_salt/py3/salt/scripts.py", line 400, in salt_call
            client.run()
          File "/var/tmp/.root_7e26e1_salt/py3/salt/cli/call.py", line 57, in run
            caller.run()
          File "/var/tmp/.root_7e26e1_salt/py3/salt/cli/caller.py", line 134, in run
            ret = self.call()
          File "/var/tmp/.root_7e26e1_salt/py3/salt/cli/caller.py", line 212, in call
            ret['return'] = func(*args, **kwargs)
          File "/var/tmp/.root_7e26e1_salt/py3/salt/modules/cp.py", line 335, in get_template
            **kwargs)
          File "/var/tmp/.root_7e26e1_salt/py3/salt/fileclient.py", line 782, in get_template
            **kwargs
          File "/var/tmp/.root_7e26e1_salt/py3/salt/utils/templates.py", line 167, in render_tmpl
            tmplstr = tmplsrc.read()
        AttributeError: 'bool' object has no attribute 'read'
    stdout:

Third way also doesn't work:

salt-ssh example.com cp.get_file salt://test.sls /dev/stdout template=jinja

example.com:
    False

Salt version 2018.3.2 on Py3.

The question is: what is the best (and documented) way to debug templates, which works consistently across salt, salt-call and salt-ssh (and maybe salt-run)?

@dwoz dwoz added Bug broken, incorrect, or confusing behavior P4 Priority 4 severity-low 4th level, cosemtic problems, work around exists severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around and removed severity-low 4th level, cosemtic problems, work around exists labels Oct 25, 2018
@dwoz
Copy link
Contributor

dwoz commented Oct 25, 2018

@max-arnold Thank you for reporting this.

@max-arnold
Copy link
Contributor Author

Any clues on how to fix this?

@limakzi
Copy link

limakzi commented Jul 24, 2019

.venv ❯ salt --version
salt 2019.2.0 (Fluorine)

I faced this problem yesterday. It highly impacts local development process.

@stale
Copy link

stale bot commented Jan 8, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Jan 8, 2020
@max-arnold
Copy link
Contributor Author

Still valid

@stale
Copy link

stale bot commented Jan 8, 2020

Thank you for updating this issue. It is no longer marked as stale.

@amendlik
Copy link
Contributor

amendlik commented Jun 1, 2020

I can work on a fix if the @dwoz or someone at Salt can offer some guidance.

@sagetherage sagetherage removed the P4 Priority 4 label Jun 3, 2020
@sagetherage sagetherage added the Magnesium Mg release after Na prior to Al label Jun 25, 2020
@sagetherage sagetherage added this to Planning in Magnesium Jun 25, 2020
@sagetherage
Copy link
Contributor

@amendlik looking to find someone who can give that guidance, thank you!

@sagetherage sagetherage removed this from the Approved milestone Jul 29, 2020
@sagetherage sagetherage added this to the Magnesium milestone Jul 29, 2020
@sagetherage sagetherage removed the Magnesium Mg release after Na prior to Al label Sep 29, 2020
@sagetherage sagetherage removed this from Planning in Magnesium Sep 29, 2020
@sagetherage sagetherage modified the milestones: Magnesium, Approved Sep 29, 2020
@andreasnuesslein
Copy link

@amendlik so I looked into the code a bit as well, if you're still interested in takling this ( / but also writing this here as a note to myself a bit):

i found out that

[DEBUG   ] Could not LazyLoad slsutil.renderer: 'slsutil.renderer' is not available.
[DEBUG   ] Performing shimmed, blocking command as follows:
slsutil.renderer /tmp/map.py

basically means: "i did not find a ssh/wrapper for slsutil, i will instead copy a kind of shim over to the node and try to execute everything there"

the shimmed version will actually work if that target file is on the host; so my test here with /tmp/map.py worked because i threw that file over onto that node. however salt:// paths will obviously not work.

a starting point to implement that slsutil to make it LazyLoad-able is the folder salt/client/ssh/wrapper/, create a file salt/client/ssh/wrapper/slsutil.py:

import logging

log = logging.getLogger(__name__)

def renderer(path=None, string=None, default_renderer="jinja|yaml", **kwargs):
    log.info("whoohoo, we found the starting point")

and then I suppose gather inspiration from the other salt/client/ssh/wrappers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
Salt-SSH
  
Severity-Medium
Development

Successfully merging a pull request may close this issue.

7 participants