Open rehan2908 opened 5 years ago
I think that #671 needs opening again because even with the environment variables line in the rabbitmq class I still get the same error about the locale.
So, I forked the repo and have managed to get past the issue by adding a utf entry for LC_ALL into the environment in the lib/puppet/provider/rabbitmq_cli.rb
file:
def self.home_tmp_command(name, path)
has_command name, path do
environment HOME: '/tmp'
+ environment LC_ALL: 'en_GB.UTF-8'
end
end
I think that the language locale just has to be available on the system and utf-8. I don't think that this is the end solution, there must be a much better way to get this working (if it was python
I could actually write the tests and get something better together to create an acutal PR to submit), but this worked for me whereas everything else was failing.
@JayH5: you have any thoughts about this one? I’d rather not hard-code env in here, and in the past, setting it in environment_variables
(default updated in #694) seemed to work.
If we hard coded it, we’d have to pick a locale, and then things wouldn’t work if the user didn’t have that locale installed.
I don’t think there are actual cases where the output requires a non-ascii character set, but this is a requirement of the underlying tool that RabbitMQ uses for CLI
@wyardley 😬 not really, haven't had this problem myself.
Adding the LC_ALL
variable to the home_tmp_command
function could work but..
LC_ALL
to a default like en_US.UTF-8
only if it's not already set.Just as a note, I didn't check whether other language settings worked here, like LANG.
LANG
would work too, I just feel like LC_ALL
is a little narrower. It’s already supposed to be defaulted in environment_variables
- @rick-pri - you’re not setting that in your Puppet code, right?
@JayH5: yeah, that’s what #694 was supposed to do, I think it sets it in the RMQ config vs in Puppet’s env directly, so wondering if somehow the new changes are causing that to get ignored or overridden, or if we can take those env vars and merge them in (that seems like it might not be a good idea though?)
Agree about renaming the function.
All of this is just one more reason that hitting the API directly is the cleanest solution.
And FWIW, setting the locale correctly on the instance itself should fix the problem. However, this affects enough users that we still need to set some kind of default.
@wyardley Sorry for the excessively long wait for me to reply to this. We're deploying on FreeBSD and I am setting a default in the login.conf
with the line:
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,LC_ALL=en_GB.UTF-8:\
What I'm wondering is if when puppet is run and it executes the rabbitmqctl command but that command doesn't inherit the shell's locale, and I can see from the rabbitmqctl
script that it doesn't set the locale:
#!/bin/sh
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
## compliance with the License. You may obtain a copy of the License
## at http://www.mozilla.org/MPL/
##
## Software distributed under the License is distributed on an "AS IS"
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
## the License for the specific language governing rights and
## limitations under the License.
##
## The Original Code is RabbitMQ.
##
## The Initial Developer of the Original Code is GoPivotal, Inc.
## Copyright (c) 2007-2017 Pivotal Software, Inc. All rights reserved.
##
# Exit immediately if a pipeline, which may consist of a single simple command,
# a list, or a compound command returns a non-zero status
set -e
# Each variable or function that is created or modified is given the export
# attribute and marked for export to the environment of subsequent commands.
set -a
# shellcheck source=/dev/null
#
# TODO: when shellcheck adds support for relative paths, change to
# shellcheck source=./rabbitmq-env
. "${0%/*}"/rabbitmq-env
HOME=/var/db/rabbitmq
run_escript rabbitmqctl_escript "${ESCRIPT_DIR:?must be defined}"/rabbitmqctl "$@"
The puppet daemon explicitly sets this when it runs:
...
# An UTF-8 locale is required
: LC_ALL=${LC_ALL:=C.UTF-8}
case $LC_ALL in
*.UTF-8)
;;
*.*)
LC_ALL="${LC_ALL%.*}.UTF-8"
;;
*)
LC_ALL=C.UTF-8
;;
esac
export LC_ALL
run_rc_command "$1"
I am having the same issue where default_user
and default_password
have been defined in a manifest. Interestingly the error does not happen on any of my 3.6 version rabbit servers, only 3.7.
Affected Puppet, Ruby, OS and module versions/distributions
How to reproduce (e.g Puppet code you use)
i am trying to use rabbitmq module to create users but i am getting this error using rabbitmq_user class using below code,
What are you seeing
and when i see locale is set to
LC_ALL=en_US.UTF-8
on the VM. and when i comment out the above code and run apuppet agent -t
then it is working as expected.What behaviour did you expect instead
rabbitmq creating users.
Output log
Any additional information you'd like to impart
is it still related to https://github.com/voxpupuli/puppet-rabbitmq/issues/671