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

Ensuring absent user_permissions with missing (or absent) user / missing (or absent) vhost #857

Open
xepa opened this issue Aug 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@xepa
Copy link
Contributor

xepa commented Aug 28, 2020

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.12.1-1bionic (agent: 6.18.0-1focal)
  • Ruby: 2.5.8
  • Distribution: Ubuntu
  • Module version: 10.1.1
  • Rabbitmq-Server: 3.8.2 / 3.8.6

How to reproduce (e.g Puppet code you use)

class { 'rabbitmq':
  service_manage    => false,
  port              => '5672',
  delete_guest_user => true,
}

rabbitmq_vhost { 'vhost':
    ensure => 'absent',
}
rabbitmq_user { 'user':
    ensure   => 'absent',
    password => 'change-me',
}
rabbitmq_user_permissions { 'user@vhost':
    ensure => 'absent',
}

What are you seeing

Some combinations of ensures in the above code will give errors (or loops in execution). This mainly happens when the user is absent (and vhost / user_permissions is either present / absent).

What behavior did you expect instead

I would expect the rabbitmq puppet module to detect the missing user and either error if the user_permissions is present or continue if user_permissions are absent (same for the vhost combination)

Output log

  1. if the vhost does not exist (but the user does)
Error: Execution of '/usr/sbin/rabbitmqctl set_permissions -p vhost user '' '' ''' returned 65: Setting permissions for user "user" in vhost "vhost" ...
Virtual host 'vhost' does not exist
Error: /Stage[main]/Rabbitmq_user_permissions[user@vhost]/ensure: change from 'absent' to 'present' failed: Execution of '/usr/sbin/rabbitmqctl set_permissions -p vhost user '' '' ''' returned 65: Setting permissions for user "user" in vhost "vhost" ...
Virtual host 'vhost' does not exist

Executing the command manually

Setting permissions for user "user" in vhost "vhost" ...
Error:
{:no_such_user, "user"}

Possible fix: read the error response

  1. The following will be repeated until a timeout
Debug: Executing: '/usr/sbin/rabbitmqctl -q status'
Debug: Executing: '/usr/sbin/rabbitmqctl list_user_permissions -q --no-table-headers user'
Debug: Command failed, retrying

Executing the command manually

# /usr/sbin/rabbitmqctl list_user_permissions -q --no-table-headers user
Error:
{:no_such_user, "user"}

Possible fix: read the error response

Any additional information you'd like to impart

Please see my test matrix below referencing reports above

Results:
vhost: present, user: present, user_permissions: present [OK]
vhost: present, user: present, user_permissions: absent  [OK]
vhost: absent,  user: present, user_permissions: present [FAILED] (1)
vhost: absent,  user: present, user_permissions: absent  [OK]
vhost: present, user: absent,  user_permissions: present [FAILED] (2)
vhost: present, user: absent,  user_permissions: absent  [FAILED] (2)
vhost: absent,  user: absent,  user_permissions: present [FAILED] (2)
vhost: absent,  user: absent,  user_permissions: absent  [FAILED] (2)
@igalic
Copy link
Contributor

igalic commented Sep 5, 2020

these autorequires might not be enough

autorequire(:rabbitmq_vhost) do
[self[:name].split('@')[1]]
end
autorequire(:rabbitmq_user) do
[self[:name].split('@')[0]]
end

@wyardley wyardley added the bug Something isn't working label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants