diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-04-25 10:55:45 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-04-25 11:02:18 -0700 |
commit | eb17a8baac262932108e61078078d7bad8027884 (patch) | |
tree | 4b850d4bc6d2d79b6d8489c69e5cf53cf57eeccb | |
parent | 7322308da2f96acb01a494152c2ccc6ced90715b (diff) | |
download | chef-eb17a8baac262932108e61078078d7bad8027884.tar.gz |
Test and better document the locale resourcetest_locale
Expand the docs a bit for the docs site.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | kitchen-tests/cookbooks/end_to_end/recipes/default.rb | 5 | ||||
-rw-r--r-- | lib/chef/resource/locale.rb | 22 |
2 files changed, 21 insertions, 6 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb index 920023b32d..54750039c5 100644 --- a/kitchen-tests/cookbooks/end_to_end/recipes/default.rb +++ b/kitchen-tests/cookbooks/end_to_end/recipes/default.rb @@ -153,6 +153,11 @@ chef_client_systemd_timer "Run chef-client as a systemd timer" do only_if { systemd? } end +locale "set system locale" do + lang "en_US.UTF-8" + only_if { debian? } +end + include_recipe "::chef-vault" unless includes_recipe?("end_to_end::chef-vault") include_recipe "::alternatives" include_recipe "::tests" diff --git a/lib/chef/resource/locale.rb b/lib/chef/resource/locale.rb index 5112e7e1df..47d11081f1 100644 --- a/lib/chef/resource/locale.rb +++ b/lib/chef/resource/locale.rb @@ -24,13 +24,23 @@ class Chef unified_mode true provides :locale - description "Use the locale resource to set the system's locale." + description "Use the locale resource to set the system's locale on Debian and Windows systems. Windows support was added in Chef Infra Client 16.0" introduced "14.5" - LC_VARIABLES = %w{LC_ADDRESS LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME}.freeze - LOCALE_CONF = "/etc/locale.conf".freeze - LOCALE_REGEX = /\A\S+/.freeze - LOCALE_PLATFORM_FAMILIES = %w{debian windows}.freeze + examples <<~DOC + Set the lang to 'en_US.UTF-8' + + ```ruby + locale 'set system locale' do + lang 'en_US.UTF-8' + end + ``` + DOC + + LC_VARIABLES ||= %w{LC_ADDRESS LC_COLLATE LC_CTYPE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME}.freeze + LOCALE_CONF ||= "/etc/locale.conf".freeze + LOCALE_REGEX ||= /\A\S+/.freeze + LOCALE_PLATFORM_FAMILIES ||= %w{debian windows}.freeze property :lang, String, description: "Sets the default system language.", @@ -38,7 +48,7 @@ class Chef validation_message: "The provided lang is not valid. It should be a non-empty string without any leading whitespaces." property :lc_env, Hash, - description: "A Hash of LC_* env variables in the form of ({ 'LC_ENV_VARIABLE' => 'VALUE' }).", + description: "A Hash of LC_* env variables in the form of `({ 'LC_ENV_VARIABLE' => 'VALUE' })`.", default: lazy { {} }, coerce: proc { |h| if h.respond_to?(:keys) |