salt-api setup, after running and get a call error 500 (foreman-proxy, saltmaster, saltapi)

379 views
Skip to first unread message

Tom K.

unread,
Feb 18, 2016, 10:33:33 AM2/18/16
to Salt-users

Hi,


I've tried to setup the salt-api like desribed in the docs as a smart-proxy to foreman.

Sofar, the SmartProxy is running and registered in foreman.


Now I try to import the salt states but I get an error 500


I've no clue what should be wrong or missing after hours of spending time to the different setup doc of salt, salt-api and foreman-proxy


==> /var/log/salt/salt-api.log


Failed to setup thread-interrupt handler. This is usually not critical

[DEBUG   ] Error while processing request for: /run

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/saltapi/netapi/rest_cherrypy/app.py", line 292, in hypermedia_handler

    ret = cherrypy.serving.request._hypermedia_inner_handler(*args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/CherryPy-5.0.1-py2.7.egg/cherrypy/_cpdispatch.py", line 60, in __call__

    return self.callable(*self.args, **self.kwargs)

  File "/usr/local/lib/python2.7/dist-packages/saltapi/netapi/rest_cherrypy/app.py", line 1106, in POST

    'return': list(self.exec_lowstate()),

  File "/usr/local/lib/python2.7/dist-packages/saltapi/netapi/rest_cherrypy/app.py", line 534, in exec_lowstate

    ret = self.api.run(chunk)

  File "/usr/local/lib/python2.7/dist-packages/saltapi/__init__.py", line 42, in run

    ret = l_fun(*f_call.get('args', ()), **f_call.get('kwargs', {}))

  File "/usr/local/lib/python2.7/dist-packages/saltapi/__init__.py", line 90, in runner

    return runner.low(fun, kwargs)

  File "/usr/lib/python2.7/dist-packages/salt/runner.py", line 135, in low

    self._verify_fun(fun)

  File "/usr/lib/python2.7/dist-packages/salt/runner.py", line 79, in _verify_fun

    raise salt.exceptions.CommandExecutionError(err)

CommandExecutionError: Function u'fileserver.envs' is unavailable

[INFO    ] 192.168.77.90 - - [18/Feb/2016:16:25:59] "POST /run HTTP/1.1" 500 57 "" "Ruby"



==> /var/log/foreman-proxy/proxy.log <==

E, [2016-02-18T16:25:59.496302 #25977] ERROR -- : Failed to list environments: Failed to query Salt API (500): {"status": 500, "return": "An unexpected error occurred"}




==> /etc/salt/master


external_auth:

  pam:

    saltuser:

      - '@runner'


rest_cherrypy:

  port: 9191

  host: 0.0.0.0

  ssl_key: /var/lib/puppet/ssl/private_keys/vmg-utf-foreman-000.pem

  ssl_crt: /var/lib/puppet/ssl/certs/vmg-utf-foreman-000.pem




SSL_ Files exists

User saltuser exists (do it need a special linux group?)




==> /etc/foreman-proxy/settings.d/salt.yml


:enabled: https

:autosign_file: /etc/salt/autosign.conf

:salt_command_user: root

# Some features require using the Salt API - such as listing environments and retrieving state info

:use_api: true

:api_url: https://vmg-utf-salt-master.to3.zone.loc:9191

:api_auth: pam

:api_username: saltuser

:api_password: saltpasswd



Would be nice if anyone can give me a hint or a kick to the right path :-)



-- Tom 

C. R. Oldham

unread,
Feb 18, 2016, 10:43:26 AM2/18/16
to salt-...@googlegroups.com
==> /etc/salt/master
external_auth:
  pam:
    saltuser:
      - '@runner'

You haven't granted your user `saltuser` access to any modules at all.  For testing purposes you might want to open this up all the way with

external_auth:
  pam:
    saltuser:
      - .*
      - '@runner'
      - '@wheel'
      - '@jobs'

And then dial it back after you get everything working.

Tom K.

unread,
Feb 18, 2016, 10:51:35 AM2/18/16
to Salt-users
Ok, I've tried it..
Same result. sobering.. :-)

C. R. Oldham

unread,
Feb 18, 2016, 3:21:38 PM2/18/16
to salt-...@googlegroups.com
OK, that was my mistake, I hadn't dug into your stacktrace enough to realize that the foreman proxy is trying to run the fileserver runner, not an execution module.

We probably should first make sure your salt-api is working.  

If you retrieve a token with

curl -sSk https://vmg-utf-salt-master.to3.zone.loc:9191/login -H 'Accept: application/x-yaml' -H 'Accept: application/x-yaml' -d username=saltuser -d password=saltpasswd -d eauth=pam

and then try running the fileserver runner with

curl -sSk https://vmg-utf-salt-master.to3.zone.loc:9191    -H 'Accept: application/x-yaml' -H 'X-Auth-Token: <token-goes-here>' -d client=runner  -d fun='fileserver.envs'

do you get something that looks like

return:
- - base

?



--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--cro
C. R. Oldham, Platform Engineer, SaltStack

Tom K.

unread,
Feb 19, 2016, 2:08:02 AM2/19/16
to Salt-users
No, that goes to the same result.
But I think my salt version (installed with debian apt.get) is to old.
I will reinstall it with bootstrap script..

Hope that helps me. I will post an update.


--Tom

Seth House

unread,
Feb 19, 2016, 5:37:16 AM2/19/16
to salt users list
On Fri, Feb 19, 2016 at 12:08 AM, 'Tom K.' via Salt-users
<salt-...@googlegroups.com> wrote:
> But I think my salt version (installed with debian apt.get) is to old.

I think you're right about that. The path in the stacktrace is from an
old version of salt-api when it was a separate project. Now that it is
merged into mainline Salt that path should look different.

Run `salt --version` and `salt-api --version` if the two don't match
then it's the wrong (old) install.

Tom K.

unread,
Feb 19, 2016, 5:09:35 PM2/19/16
to Salt-users, se...@eseth.com
Hi,

I've bootstrapped a saltmaster, again with foreman-proxy. This seems running. 
Now, again, the salt api... Now it endsup earlier. During start of salt-api. But here is again an exception which
really  don't show me a hint what I can do to let it run

Oh, my 2 Versions are :

vmg-utf-saltmaster-000:/# salt-master --version

salt-master 2015.8.7 (Beryllium)

vmg-utf-saltmaster-000:/# salt-api --version

salt-api 0.8.4.1


Installed like

And Salt-Api like
and a little bit from

tar xvzf CherryPy-5.0.1.tar.gz
cd CherryPy-5.0.1
python setup.py install

python get-pip.py 
pip install salt-api


==> /etc/salt/master

external_auth:

  pam:

    saltuser:

      - .*

      - '@runner'

      - '@wheel'

      - '@jobs'


rest_cherrypy:

  port: 9191

  host: 0.0.0.0

  ssl_key: /var/lib/puppet/ssl/private_keys/vmg-utf-foreman-000.to3.zone.loc.pem

  ssl_crt: /var/lib/puppet/ssl/certs/vmg-utf-foreman-000.to3.zone.loc.pem



==>/etc/foreman-proxy/settings.d/salt.yml

:enabled: https

:autosign_file: /etc/salt/autosign.conf

:salt_command_user: root

# Some features require using the Salt API - such as listing environments and retrieving state info

:use_api: true

:api_auth: pam

:api_username: saltuser

:api_password: saltpasswd




And my result at this time :


vmg-utf-saltmaster-000:/# salt-api -l trace --log-file=/var/log/salt/salt-api.log --log-file-level=trace

[DEBUG   ] Reading configuration from /etc/salt/master

[DEBUG   ] Using cached minion ID from /etc/salt/minion_id: vmg-utf-saltmaster-000.to3.zone.loc

[TRACE   ] None of the required configuration sections, 'logstash_udp_handler' and 'logstash_zmq_handler', were found the in the configuration. Not loading the Logstash logging handlers module.

[TRACE   ] The required configuration section, 'fluent_handler', was not found the in the configuration. Not loading the fluent logging handlers module.

[DEBUG   ] Configuration file path: /etc/salt/master

[DEBUG   ] Created pidfile: /var/run/salt-api.pid

[ERROR   ] An un-handled exception was caught by salt's global exception handler:

AttributeError: 'module' object has no attribute '_create_loader'

Traceback (most recent call last):

  File "/usr/local/bin/salt-api", line 11, in <module>

    main()

  File "/usr/local/bin/salt-api", line 8, in main

    sapi.run()

  File "/usr/local/lib/python2.7/dist-packages/saltapi/cli.py", line 67, in run

    client.run()

  File "/usr/local/lib/python2.7/dist-packages/saltapi/client.py", line 23, in run

    netapi = saltapi.loader.netapi(self.opts)

  File "/usr/local/lib/python2.7/dist-packages/saltapi/loader.py", line 16, in netapi

    load = salt.loader._create_loader(

AttributeError: 'module' object has no attribute '_create_loader'

Traceback (most recent call last):

  File "/usr/local/bin/salt-api", line 11, in <module>

    main()

  File "/usr/local/bin/salt-api", line 8, in main

    sapi.run()

  File "/usr/local/lib/python2.7/dist-packages/saltapi/cli.py", line 67, in run

    client.run()

  File "/usr/local/lib/python2.7/dist-packages/saltapi/client.py", line 23, in run

    netapi = saltapi.loader.netapi(self.opts)

  File "/usr/local/lib/python2.7/dist-packages/saltapi/loader.py", line 16, in netapi

    load = salt.loader._create_loader(

AttributeError: 'module' object has no attribute '_create_loader'



-- Tom

Seth House

unread,
Feb 19, 2016, 6:22:58 PM2/19/16
to salt users list
On Fri, Feb 19, 2016 at 3:09 PM, 'Tom K.' via Salt-users
<salt-...@googlegroups.com> wrote:
> pip install salt-api

This is where the mismatch is happening. Since salt-api ships with
Salt you only need to install Salt.

1. Use pip to uninstall salt-api.
2. Reinstall Salt the same way to did before.
3. Run `salt-api --version`.

Tom K.

unread,
Feb 20, 2016, 3:23:03 AM2/20/16
to Salt-users, se...@eseth.com
Hi,

I've tried. But after installing the bootstrap way, there is still no salt-api installed.
I don't know if debian jessie is the problem. Will try another linux dist.

curl -L https://bootstrap.saltstack.com -o install_salt.sh
sudo sh install_salt.sh -P -M

:-/

Seth House

unread,
Feb 20, 2016, 2:59:51 PM2/20/16
to salt users list

Sounds like a bootstrap bug. Please file an issue in that repository.

In the meantime `apt-get install salt-api` should do the trick.

It's a tad confusing since the pip command of the same name is incorrect. It's because the Debian packages are split apart when they're created, whereas the correct PyPI install is just plain 'salt'.

--

Tom K.

unread,
Feb 20, 2016, 3:06:07 PM2/20/16
to Salt-users, se...@eseth.com
Yes, I've got it running in the meantime. Have got a snapshot and do a clean install with apt-get.
Seems working now. But there are always some "features" and stones on my way to become a working
foreman/salt constellation... :-) But now it's in foreman :-)

Thanks for help!
Reply all
Reply to author
Forward
0 new messages