Salt: Rabbitmq module fails with version below 3.5.6

Created on 26 May 2017  路  6Comments  路  Source: saltstack/salt

Description of Issue/Question

During deployment of rabbitmq-sever, function check_password in rabbitmq module salt module fails with following error:

          ID: rabbit_user_admin_present
    Function: rabbitmq_user.present
        Name: admin
      Result: False
     Comment: Error: RabbitMQ command failed: Error: {undef,
                         [{rabbit_auth_backend_internal,check_user_login,
                              [<<"admin">>,[{password,<<"My_pass">>}]],
                              []},
                          {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,669}]},
                          {rpc,'-handle_call_call/6-fun-0-',5,
                              [{file,"rpc.erl"},{line,206}]}]}
     Started: 19:02:25.308927
    Duration: 2220.047 ms
     Changes:   

I did some investigation, it turns out that root cause is wrong command used to check if user with this provided password already exists

    cmd = ('rabbit_auth_backend_internal:check_user_login'
        '(<<"{0}">>, [{{password, <<"{1}">>}}]).').format(
        name.replace('"', '\\"'),
        password.replace('"', '\\"'))

However, according to rabbitmq-server repos for versions 3.5.6 and below, check_user_login function is not used this way. It should be called using other function, called user_login_authentication
so I've changed the cmd to:

    cmd = ('rabbit_auth_backend_internal:user_login_authentication'
        '(<<"{0}">>, [{{password, <<"{1}">>}}]).').format(
        name.replace('"', '\\"'),
        password.replace('"', '\\"'))

and everything appears to be working

Setup

OS: ubuntu trusty 14.04
rabbitmq-server version:

(jse2)root@rmq-01:~# rabbitmqctl status                                                                                                                                                                                                                               
Status of node 'rabbit@rmq-01' ...
[{pid,1154},
 {running_applications,
     [{rabbitmq_management,"RabbitMQ Management Console","3.5.6"},
      {amqp_client,"RabbitMQ AMQP Client","3.5.6"},
      {rabbitmq_web_dispatch,"RabbitMQ Web Dispatcher","3.5.6"},
      {webmachine,"webmachine","1.10.3-rmq3.5.6-gite9359c7"},
      {rabbitmq_management_agent,"RabbitMQ Management Agent","3.5.6"},
      {rabbit,"RabbitMQ","3.5.6"},
      {os_mon,"CPO  CXC 138 46","2.4"},
      {mochiweb,"MochiMedia Web Server","2.7.0-rmq3.5.6-git680dba8"},
      {xmerl,"XML parser","1.3.8"},
      {mnesia,"MNESIA  CXC 138 12","4.13.1"},
      {inets,"INETS  CXC 138 49","6.0.1"},
      {sasl,"SASL  CXC 138 11","2.6"},
      {stdlib,"ERTS  CXC 138 10","2.6"},
      {kernel,"ERTS  CXC 138 10","4.1"}]},
 {os,{unix,linux}},

SLS file:

{%- from "rabbitmq/map.jinja" import server, rabbitmq_users with context %}
{%- if server.enabled %}

include:
- rabbitmq.server.service

{%- if server.admin is defined %}

rabbit_user_admin_present:
  rabbitmq_user.present:
  - name: {{ server.admin.name }}
  - password: {{ server.admin.password }}
  - force: True
  - tags: administrator
  - perms:
    {%- for vhost_name, vhost in server.get('host', {}).iteritems() %}
    - '{{ vhost_name }}':
      - '.*'
      - '.*'
      - '.*'
    {%- endfor %}
  - require:
    - service: rabbitmq_service

{%- endif %}

{%- if 'guest' not in rabbitmq_users.keys() %}
{#- Delete default guest user if we are not using it #}
rabbitmq_user_guest_absent:
  rabbitmq_user.absent:
  - name: guest
  - require:
    - service: rabbitmq_service
{%- endif %}

{%- endif %}

Steps to Reproduce Issue

  1. Install rabbitmq-server, version below 3.5.6
  2. Apply rabbitmq_user.present
  3. fail

    Versions Report

Salt Version:
           Salt: 2016.3.5

Dependency Versions:
           cffi: 1.1.2
       cherrypy: Not Installed
       dateutil: 2.4.2
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.8
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: 1.0.2
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.3.4
      pycparser: 2.10
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.6 (default, Oct 26 2016, 20:30:19)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.19.0-79-generic
         system: Linux
        version: Ubuntu 14.04 trusty
Bug RIoT State Module severity-medium

Most helpful comment

Same with Salt 3000 and RabbitMQ 3.8.2.

ID: rabbitmq_user_user Function: rabbitmq_user.present Name: user Result: False Comment: Error: RabbitMQ command failed: Error: {:undef, [{:rabbit_auth_backend_internal, :check_user_login, ["user", [password: "<password>"]], []}, {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]}, {:rpc, :"-handle_call_call/6-fun-0-", 5, [file: 'rpc.erl', line: 197]}]} Started: 16:40:34.001354 Duration: 1902.499 ms Changes:

All 6 comments

@teoyaomiqui Thanks for the PR! I will close this issue since there is a fix, but if there are issues with the fix please let us know and we can re-open the issue. Thanks

PR is being discussed, and it is not merged, i think that it is a little bit early to close this issue

I am running salt 2019.2.3 with rabbitmq 3.8.2 and this is still an issue.

      ID: rabbitmq_proton
Function: rabbitmq_user.present
    Name: proton
  Result: False
 Comment: Error: RabbitMQ command failed: Error:
          {:undef, [{:rabbit_auth_backend_internal, :check_user_login, ["<<user>>", [password: "<<password>>"]], []}, {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]}, {:rpc, :"-handle_call_call/6-fun-0-", 5, [file: 'rpc.erl', line: 197]}]}
 Started: 18:35:53.993985
Duration: 26194.655 ms
 Changes:

Same with Salt 3000 and RabbitMQ 3.8.2.

ID: rabbitmq_user_user Function: rabbitmq_user.present Name: user Result: False Comment: Error: RabbitMQ command failed: Error: {:undef, [{:rabbit_auth_backend_internal, :check_user_login, ["user", [password: "<password>"]], []}, {:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 680]}, {:rpc, :"-handle_call_call/6-fun-0-", 5, [file: 'rpc.erl', line: 197]}]} Started: 16:40:34.001354 Duration: 1902.499 ms Changes:

/reopen

@Ch3LL plz reopen this issue because it's not resolved

Was this page helpful?
0 / 5 - 0 ratings