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

salt-ssh + mine = weird error #34526

Closed
danielmotaleite opened this issue Jul 7, 2016 · 3 comments
Closed

salt-ssh + mine = weird error #34526

danielmotaleite opened this issue Jul 7, 2016 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Milestone

Comments

@danielmotaleite
Copy link
Contributor

danielmotaleite commented Jul 7, 2016

I'm testing a salt-ssh setup with mine and have this teste.sls state file:

# Get all machines instances on saltmaster
{% for host, hostinfo in salt['mine.get']('*','network.interfaces').items() -%}
/tmp/{{ hosts }}/:
  file.directory
{% endfor %}

with this roaster

server:
  host: server
  user: root
  tty:  True
  mine_functions:
    network.interfaces: []
    grains.get: ['roles']

The mine.get returns:

 salt-ssh   server   mine.get '*' network.interfaces  
server:
    ----------
    server:
        ----------
        eth0:
            ----------
            hwaddr:
                52:54:00:36:83:ef
            inet:
                |_
                  ----------
                  address:
                      192.168.75.53
                  broadcast:
                      192.168.75.255
                  label:
                      eth0
                  netmask:
                      255.255.255.0
            inet6:
                |_
                  ----------
                  address:
                      fe80::5054:ff:fe36:83ef
                  prefixlen:
                      64
                  scope:
                      link
            up:
                True
        eth1:
            ----------
            hwaddr:
                52:54:00:16:e7:ba
            inet:
                |_
                  ----------
                  address:
                      192.168.71.53
                  broadcast:
                      192.168.71.255
                  label:
                      eth1
                  netmask:
                      255.255.255.0
            inet6:
                |_
                  ----------
                  address:
                      fe80::5054:ff:fe16:e7ba
                  prefixlen:
                      64
                  scope:
                      link
            up:
                True
        lo:
            ----------
            hwaddr:
                00:00:00:00:00:00
            inet:
                |_
                  ----------
                  address:
                      127.0.0.1
                  broadcast:
                      None
                  label:
                      lo
                  netmask:
                      255.0.0.0
            inet6:
                |_
                  ----------
                  address:
                      ::1
                  prefixlen:
                      128
                  scope:
                      host
            up:
                True

but doing this command returns this outpupt:

$ salt-ssh   server    state.sls teste
[ERROR   ] Rendering exception occurred: Jinja error: 'python2_bin'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 366, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 2, in top-level template code
  File "/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/mine.py", line 48, in get
    ssh = salt.client.ssh.SSH(opts)
  File "/usr/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 288, in __init__
    python2_bin=self.opts['python2_bin'],
KeyError: 'python2_bin'

; line 2

---
# Get all machines instances on saltmaster
{% for host, hostinfo in salt['mine.get']('*','network.interfaces').items() -%}    <======================
/tmp/{{ hosts }}/:
  file.directory
{% endfor %}

Traceback (most recent call last):
[...]

---
[CRITICAL] Rendering SLS 'base:teste' failed: Jinja error: 'python2_bin'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 366, in render_jinja_tmpl
    output = template.render(**decoded_context)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 2, in top-level template code
  File "/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/mine.py", line 48, in get
    ssh = salt.client.ssh.SSH(opts)
  File "/usr/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 288, in __init__
    python2_bin=self.opts['python2_bin'],
KeyError: 'python2_bin'

; line 2

---
# Get all machines instances on saltmaster
{% for host, hostinfo in salt['mine.get']('*','network.interfaces').items() -%}    <======================
/tmp/{{ hosts }}/:
  file.directory
{% endfor %}

Traceback (most recent call last):
[...]

---
server:
    - Rendering SLS 'base:teste' failed: Jinja error: 'python2_bin'
      Traceback (most recent call last):
        File "/usr/lib/python2.7/site-packages/salt/utils/templates.py", line 366, in render_jinja_tmpl
          output = template.render(**decoded_context)
        File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
          return self.environment.handle_exception(exc_info, True)
        File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
          reraise(exc_type, exc_value, tb)
        File "<template>", line 2, in top-level template code
        File "/usr/lib/python2.7/site-packages/salt/client/ssh/wrapper/mine.py", line 48, in get
          ssh = salt.client.ssh.SSH(opts)
        File "/usr/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 288, in __init__
          python2_bin=self.opts['python2_bin'],
      KeyError: 'python2_bin'

      ; line 2

      ---
      # Get all machines instances on saltmaster
      {% for host, hostinfo in salt['mine.get']('*','network.interfaces').items() -%}    <======================
      /tmp/{{ hosts }}/:
        file.directory
      {% endfor %}

      Traceback (most recent call last):
      [...]
      ---

and i'm totally lost why

@danielmotaleite
Copy link
Contributor Author

i forgot, i'm using salt-ssh 2016.3.1 (Boron) and of course, running a simple test.sls with

/tmp/test/:
  file.directory

works fine

@Ch3LL
Copy link
Contributor

Ch3LL commented Jul 8, 2016

@danielmotaleite I believe this is related to #27808, but i'll leave both open because I don't believe they are duplicates since the other issue specifically addresses using aliases in salt-ssh.

I am able to replicate this behavior using the following sls file:

{% for server, addrs in salt['mine.get']('*', 'network.ip_addrs') | dictsort() %}
echo "server {{ server }} {{ addrs[0] }}:80 check":
  cmd.run
{% endfor %}

I can run this find without salt-ssh:

 ch3ll@localhost  ~/git/salt  ➦ 06f2499  sudo salt '10*' state.sls issues.34526
10.1.45.255:
----------
          ID: echo "server 10.1.45.255 10.1.45.255:80 check"
    Function: cmd.run
      Result: True
     Comment: Command "echo "server 10.1.45.255 10.1.45.255:80 check"" run
     Started: 10:08:24.028712
    Duration: 10.944 ms
     Changes:   
              ----------
              pid:
                  24453
              retcode:
                  0
              stderr:
              stdout:
                  server 10.1.45.255 10.1.45.255:80 check

Summary for 10.1.45.255
------------
Succeeded: 1 (changed=1)
Failed:    0
------------
Total states run:     1

But when attempting this with salt-ssh:

ch3ll-minion01:
    - Rendering SLS 'base:issues.34526' failed: Jinja error: 'python2_bin'
      Traceback (most recent call last):
        File "/home/ch3ll/git/salt/salt/utils/templates.py", line 366, in render_jinja_tmpl
          output = template.render(**decoded_context)
        File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
          return self.environment.handle_exception(exc_info, True)
        File "/usr/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
          reraise(exc_type, exc_value, tb)
        File "<template>", line 1, in top-level template code
        File "/home/ch3ll/git/salt/salt/client/ssh/wrapper/mine.py", line 48, in get
          ssh = salt.client.ssh.SSH(opts)
        File "/home/ch3ll/git/salt/salt/client/ssh/__init__.py", line 288, in __init__
          python2_bin=self.opts['python2_bin'],
      KeyError: 'python2_bin'

      ; line 1

      ---
      {% for server, addrs in salt['mine.get']('*', 'network.ip_addrs') | dictsort() %}    <======================
      echo "server {{ server }} {{ addrs[0] }}:80 check":
        cmd.run
      {% endfor %}

      Traceback (most recent call last):
      [...]
      ---

Thanks for catching and reporting this. we will need to get this fixe dup.

@Ch3LL Ch3LL added Bug broken, incorrect, or confusing behavior P3 Priority 3 severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around Core relates to code central or existential to Salt Salt-SSH labels Jul 8, 2016
@Ch3LL Ch3LL added this to the Approved milestone Jul 8, 2016
@thatch45
Copy link
Contributor

@danielmotaleite the above PR resolves it for me, thanks for the find!

@rallytime rallytime added the fixed-pls-verify fix is linked, bug author to confirm fix label Jul 20, 2016
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 Core relates to code central or existential to Salt fixed-pls-verify fix is linked, bug author to confirm fix P3 Priority 3 Salt-SSH severity-medium 3rd level, incorrect or bad functionality, confusing and lacks a work around
Projects
None yet
Development

No branches or pull requests

5 participants