[chef] Re: Issues with Locale on Remote Client Node when running knife ssh: chef-client for Ubuntu 12.04 and chef 10 or chef 11


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Issues with Locale on Remote Client Node when running knife ssh: chef-client for Ubuntu 12.04 and chef 10 or chef 11
  • Date: Fri, 26 Apr 2013 08:28:35 -0700


On Friday, April 26, 2013 at 1:27 AM, wrote:

Currently I'm using chef 11 (just upgraded, hoping the problem would go away
but it hasn't!)

So here's my problem.

When I type the command "locale" on my ubuntu machine the default output I get
is the following:

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Assume that I have a cook book that will write a locale to a temp file in a
recipe and cookbook

knife node run_list add server1 recipe[writelocale]

the following is the contents of the recipe/writelocale.rb

execute "locale" do
command "locale >> /tmp/locale.txt"
end
This is a tricky one. The underlying mixlib-shellout library that Chef uses to run commands sets the locale to "C" to avoid encoding issues and get consistent output from localized programs (Chef has to parse output from many commands and this doesn't work if you unexpectedly get Spanish output).

This is documented in the code here: https://github.com/opscode/mixlib-shellout/blob/master/lib/mixlib/shellout.rb#L124

I think you should be able to add `environment "LC_ALL" => nil` to your execute command to override this.

HTH,

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§