saz / puppet-locales Goto Github PK
View Code? Open in Web Editor NEWManage locales with puppet
License: Other
Manage locales with puppet
License: Other
Hi,
We started using this module and found it's failing with 'Error 400 on SERVER: No matching value for selector param 'CentOS' at /etc/puppet/modules/locales/manifests/params.pp:6' on our CentOS servers. It'd be really nice if it works on CentOS in general, but I'd be happy if it just defaulted to give a warning and not fail, breaking Puppet entirely on those.
Anyways, thank you for writing and publishing this module; it should help a lot with ensuring consistent locales in our environment. I'll work on writing a fix for this unless someone else gets to it first.
Sincerely,
Teran
Can you have an option to manage_package or something? I have another module that package declares 'glibc-common', which winds up as a duplicate package conflict.
Then I believe I could, for example, hiera set locales::manage_package:false and not hit the duplicate package declaration.
The default value for $config_file
is wrong for ArchLinux. It is currently:
$config_file = '/etc/locales.gen'
It should be:
$config_file = '/etc/locale.gen'
It is possible to work around this be manually setting config_file
as a parameter, eg:
class { 'locales':
default_locale => 'en_US.UTF-8',
locales => ['en_US.UTF-8 UTF-8', 'fr_CH.UTF-8 UTF-8'],
config_file => '/etc/locale.gen',
}
I need to set locales in RedHat/CentOS using a puppet module and I think it would be an interesting feature for the puppet-locales. From what I saw the way of setting locales in RedHat/CentOS is quite different from Ubuntu/Debian. What would be the best way to do this?
To add a new locale the CentOS use:
localedef -i <language> -f <encoding> <locale_name>
To set the default language and others locales variables we edit the file /etc/sysconfig/i18n. For example:
LANG="pt_BR.UTF-8"
LC_CTYPE="pt_BR.UTF-8"
LC_NUMERIC="pt_BR.UTF-8"
LC_TIME="pt_BR.UTF-8"
LC_COLLATE="pt_BR.UTF-8"
LC_MONETARY="pt_BR.UTF-8"
LC_MESSAGES="pt_BR.UTF-8"
LC_PAPER="pt_BR.UTF-8"
LC_NAME="pt_BR.UTF-8"
LC_ADDRESS="pt_BR.UTF-8"
LC_TELEPHONE="pt_BR.UTF-8"
LC_MEASUREMENT="pt_BR.UTF-8"
LC_IDENTIFICATION="pt_BR.UTF-8"
Just noting this here so I don't forget about it and can submit a PR later: it would be nice if this module supported setting more locale variables, like LC_TIME
or any other LC_*
variables.
The locales in locale.gen are ignored by the locale-gen command in Ubuntu (at least in Ubuntu 12.04).
From what I can see you should update the file /var/lib/locales/supported.d/local which does have an effect on the locales generated by locale-gen
Hi,
I get a 'Unsupported platform: RedHat' message when I try to apply your lovely module.
# facter operatingsystem
RedHat
When I change the Redhat to RedHat in the case statement in params.pp it works fine.
Sorry no pull request, I can't push to github from work.
Thanks,
Frank
Because of version_requirement >= 4.0.0 < 5.0.0 in metadata.json, puppet 5 is not supported.
Most probably, this will just work on puppet 5, and the version requirement can be updated to < 6.0.0
Hello, hello.
First thank you for your effort about writing this nice module. Everything about it simply works, except the fact we need support for modern distributions like Rocky ;-)
I tried to roll out today on Rocky and got this error:
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Unsupported platform: Rocky (file: /etc/puppetlabs/code/environments/production/modules/locales/manifests/params.pp, line: 103, column: 7) on node scout.home.lan
So I'm kindly pleasing you to add that support to the selector when you have time.
Thanks in advance.
i am running debian stretch and manage my locales with puppet.
my /etc/locale.gen
looks quite nice:
# File managed by puppet
en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8
but quite often i notice that the file must have been touched by another app because if i do a puppetrun is see that all the default comments are removed again:
...
==> myserver.example.com: -# uz_UZ@cyrillic UTF-8
==> myserver.example.com: -# ve_ZA UTF-8
==> myserver.example.com: -# vi_VN UTF-8
==> myserver.example.com: -# wa_BE ISO-8859-1
==> myserver.example.com: -# wa_BE.UTF-8 UTF-8
==> myserver.example.com: -# wa_BE@euro ISO-8859-15
==> myserver.example.com: -# wae_CH UTF-8
==> myserver.example.com: -# wal_ET UTF-8
==> myserver.example.com: -# wo_SN UTF-8
==> myserver.example.com: -# xh_ZA ISO-8859-1
==> myserver.example.com: -# xh_ZA.UTF-8 UTF-8
==> myserver.example.com: -# yi_US CP1255
==> myserver.example.com: -# yi_US.UTF-8 UTF-8
==> myserver.example.com: -# yo_NG UTF-8
==> myserver.example.com: -# yue_HK UTF-8
...
does someone know why this happens? which app / cron job always my puppet managed locale file?
maybe this cause can directly prevented in this module.
does the locale package gets so often updated? i am running unattendet updates, so this can also be a reason.
Thank you for your excellent puppet module.
I am just wondering the license type this project is licensed under? Probably adding LICENSE file would be a great idea.
Thank you in advance.
Some references:
Hi,
I've found a number of machines do not have /etc/default/locale generated.
I use your package as:
class {'locales':
autoupgrade => true,
locales => 'en_US.UTF-8 UTF-8',
}
From searching around, it appears that either reconfiguring locales (on Debian) https://giantdorks.org/alain/error-unable-to-open-env-file-etcdefaultlocale-no-such-file-or-directory/ or running 'update-locales' fixes the problem http://superuser.com/questions/236023/unable-to-open-env-file-etc-default-locale-no-such-file-or-directory
Perhaps one of those should also be done (as a notify?)
Hey Saz,
Can you update the Puppet forge page to state that the module supports Archlinux?
I was going to add support and send you a PR but on closer inspection there is already support in the module but it is not listed as such on Puppet forge.
Thanks,
Alan
Sangoma is the "OS" for freepbx, which is a RHEL clone
diff --git a/manifests/params.pp b/manifests/params.pp
index 6331242..504aa1c 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -59,7 +59,7 @@ class locales::params {
}
}
}
- /(RedHat|CentOS|OracleLinux|Fedora|Amazon|CloudLinux|AlmaLinux|Rocky)/: {
+ /(RedHat|CentOS|OracleLinux|Fedora|Amazon|CloudLinux|AlmaLinux|Rocky|Sangoma)/: {
$package = 'glibc-common'
$update_locale_pkg = false
$locale_gen_cmd = undef
I'm running puppet with ordering = random
to help me learn about Puppet(for a vagrant machine, so wanting to run puppet once and that's it.)
Unfortunately I keep getting errors from puppet-locales
where the update-locales
command is being run before the locale-gen
command meaning the locale I want to set(en_NZ.UTF-8
) doesn't exist.
This is a RHEL 8 rebuild, same as (currently) CentOS, AlmaLinux, etc.
# facter os.name
Rocky
This seems to be all that's needed to fix it:
/(RedHat|CentOS|OracleLinux|Fedora|Amazon|CloudLinux|AlmaLinux|Rocky)/: {
I can do that as a patch or a PR if you prefer.
It seems the module works well with Puppet 8. Maybe it's time to add support fo manifest.json?
Hello.
First of all, it is a great module. Thanks for your work.
May I ask you to consider adding a LICENSE to it?
Hello.
I have basic vagrant machine (ubuntu/trusty64), and I tested only locales (I got sources from github), so my default.pp =
class { 'locales':
default_locale => 'pl_PL.UTF-8',
locales => ['pl_PL.UTF-8 UTF-8', 'en_US.UTF-8 UTF-8'],
}
After first start, I can login by vagrant ssh, but after "locale" I see:
vagrant@some-project-dev-box:~$ locale
LANG=pl_PL.UTF-8"
LANGUAGE=
"C_CTYPE="pl_PL.UTF-8"
"C_NUMERIC="pl_PL.UTF-8"
"C_TIME="pl_PL.UTF-8"
"C_COLLATE="pl_PL.UTF-8"
"C_MONETARY="pl_PL.UTF-8"
"C_MESSAGES="pl_PL.UTF-8"
"C_PAPER="pl_PL.UTF-8"
"C_NAME="pl_PL.UTF-8"
"C_ADDRESS="pl_PL.UTF-8"
"C_TELEPHONE="pl_PL.UTF-8"
"C_MEASUREMENT="pl_PL.UTF-8"
"C_IDENTIFICATION="pl_PL.UTF-8"
LC_ALL=
But it should be:
LANG=pl_PL.UTF-8
LANGUAGE=
C_CTYPE="pl_PL.UTF-8"
C_NUMERIC="pl_PL.UTF-8"
C_TIME="pl_PL.UTF-8"
C_COLLATE="pl_PL.UTF-8"
C_MONETARY="pl_PL.UTF-8"
C_MESSAGES="pl_PL.UTF-8"
C_PAPER="pl_PL.UTF-8"
C_NAME="pl_PL.UTF-8"
C_ADDRESS="pl_PL.UTF-8"
C_TELEPHONE="pl_PL.UTF-8"
C_MEASUREMENT="pl_PL.UTF-8"
C_IDENTIFICATION="pl_PL.UTF-8"
LC_ALL=
And after vagrant halt, I can't again run vagrant.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
Since all major distribution support systemd, this module may use localctl instead define the $locale::default_file
manually. For example:
# localectl set-locale LANG=en_US.utf8 LANGUAGE=en_US.utf8 LC_CTYPE=en_US.utf8
Could you please add a changelog of changes as other Puppet Forge contributors do?
hi, I use your module on my servers, and it was whether it was possible to release version 2.0.1 on puppet forge?
In advance thank you! (for default_locales parameter :-))
The $default_file = /etc/default/locale
directive should be changed to $default_file = '/etc/locale.conf'
at least for Debian 12 in the file manifests/params.pp.
Hello,
Gentoo is provoking a warning in puppetserver:
2022-04-15T13:36:32.320Z WARN [qtp1144132856-5237] [puppetserver] Puppet Unknown variable: 'locales::params::update_locale_cmd'. (file: /etc/puppetlabs/code/environments/production/modules/locales/manifests/init.pp, line: 146, column: 51)
The correction is quite simple, in manifests/params.pp, it's missing an undef for update_locale_cmd; patch enclosed.
Thanks !
gentoo.txt
I'm always getting the following error message back from Puppet:
Error: /Stage[main]/Locales/Exec[locale-gen]: Failed to call refresh: /usr/sbin/locale-gen: 24: /usr/sbin/locale-gen: rm: not found
Generating locales (this might take a while)...
/usr/sbin/locale-gen: 1: /usr/sbin/locale-gen: sed: not found
.UTF-8/usr/sbin/locale-gen: 1: /usr/sbin/locale-gen: sed: not found
.../usr/sbin/locale-gen: 1: /usr/sbin/locale-gen: sed: not found
Error: /Stage[main]/Locales/Exec[locale-gen]: /usr/sbin/locale-gen: 24: /usr/sbin/locale-gen: rm: not found
Generating locales (this might take a while)...
/usr/sbin/locale-gen: 1: /usr/sbin/locale-gen: sed: not found
.UTF-8/usr/sbin/locale-gen: 1: /usr/sbin/locale-gen: sed: not found
.../usr/sbin/locale-gen: 1: /usr/sbin/locale-gen: sed: not found
I call your module with the following arguments within my manifest:
class { "locales":
default_locale => "en_US.UTF-8",
autoupgrade => true,
}
Now the funny part, if I change the params.pp
file of your module (line 12 and 13):
$locale_gen_cmd = 'sudo /usr/sbin/locale-gen'
$update_locale_cmd = 'sudo /usr/sbin/update-locale'
Now everything works just fine and as expected. Any idea?
Liebe Grüße
PS: Could it be that the exec
calls just need a path
set to search in for the missing rm
and sed
commands. I'm out of time right now, so can't test, but will do so later and report back (unless you've found a solution before I have).
puppet-locales version 2.3.0
puppet definition:
class { 'locales':
default_locale => 'en_HK.UTF-8',
locales => ['en_HK.UTF-8'],
lc_ctype => 'en_HK.UTF-8',
lc_collate => 'en_HK.UTF-8',
lc_time => 'en_HK.UTF-8',
lc_numeric => 'en_HK.UTF-8',
lc_monetary => 'en_HK.UTF-8',
lc_messages => 'en_HK.UTF-8',
lc_paper => 'en_HK.UTF-8',
lc_name => 'en_HK.UTF-8',
lc_address => 'en_HK.UTF-8',
lc_telephone => 'en_HK.UTF-8',
lc_measurement => 'en_HK.UTF-8',
lc_identification => 'en_HK.UTF-8',
}
Error:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_HK.UTF-8",
LC_MONETARY = "en_HK.UTF-8",
LC_CTYPE = "en_HK.UTF-8",
LC_COLLATE = "en_HK.UTF-8",
LC_ADDRESS = "en_HK.UTF-8",
LC_TELEPHONE = "en_HK.UTF-8",
LC_MESSAGES = "en_HK.UTF-8",
LC_NAME = "en_HK.UTF-8",
LC_MEASUREMENT = "en_HK.UTF-8",
LC_IDENTIFICATION = "en_HK.UTF-8",
LC_NUMERIC = "en_HK.UTF-8",
LC_PAPER = "en_HK.UTF-8",
LANG = "en_HK.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
How could I fix this issue?
Same as CentOS
Here is a rough plan for anybody wanting to add Archlinux
(capitalization is exactly this):
$package = 'glibc'
$update_locale_pkg = false
$locale_gen_cmd = '/usr/bin/locale-gen' # /usr/sbin will also work but considered legacy
$config_file = '/etc/locales.gen'
$default_file = '/etc/locale.conf'
I don't know Puppet well yet to attempt a PR.
Puppet apparently has huge issues wrt non-ASCII characters and locales.
With this module it is already possible to modify /etc/default/locale
with the locales::default_locale
parameter. Would it make sense to append the same value as LANG
or LC_ALL
in /etc/environment
?
Class is changing default locale config but does not check if locale is present/generated in the system.
Asking puppet apply to do this
class english {
class { 'locales':
default_locale => 'en_GB.UTF-8',
locales => ['en_GB.UTF-8 UTF-8', 'en_US.UTF-8 UTF-8'],
}
}
leads to death thus:
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_rmdir - /var/lib/locales/supported.d/local20161004-32612-1qyuldy.lock at 191:/etc/puppet/modules/locales/manifests/init.pp
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_rmdir - /var/lib/locales/supported.d/local20161004-32612-1qyuldy.lock at 191:/etc/puppet/modules/locales/manifests/init.pp
Wrapped exception:
No such file or directory @ dir_s_rmdir - /var/lib/locales/supported.d/local20161004-32612-1qyuldy.lock
Error: /Stage[main]/Locales/File[/var/lib/locales/supported.d/local]/ensure: change from absent to file failed: Could not set 'file' on ensure: No such file or directory @ dir_s_rmdir - /var/lib/locales/supported.d/local20161004-32612-1qyuldy.lock at 191:/etc/puppet/modules/locales/manifests/init.pp
Notice: /Stage[main]/Locales/Exec[locale-gen]: Dependency File[/var/lib/locales/supported.d/local] has failures: true
Warning: /Stage[main]/Locales/Exec[locale-gen]: Skipping because of failed dependencies
The missing file /var/lib/locales/supported.d
is probably a red herring, since it appears to be create on successful locale generation (cf. here).
The bug appears to exist both in the version pulled from puppet forge and that from github.
I'm using puppet 3.8.5.
If there is no language pack installed on Ubuntu (tested on 16.04 xenial), the directory /var/lib/locales/supported.d
does not exist. This makes the locales module fail, because it tries to create the file local
in that directory without making sure it exists:
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /var/lib/locales/supported.d/local20160608-22855-1nxbc2h.lock at 184:/etc/puppet/code/environments/production/modules/locales/manifests/init.pp
Error: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /var/lib/locales/supported.d/local20160608-22855-1nxbc2h.lock at 184:/etc/puppet/code/environments/production/modules/locales/manifests/init.pp
Wrapped exception:
No such file or directory @ dir_s_mkdir - /var/lib/locales/supported.d/local20160608-22855-1nxbc2h.lock
Error: /Stage[main]/Locales/File[/var/lib/locales/supported.d/local]/ensure: change from absent to file failed: Could not set 'file' on ensure: No such file or directory @ dir_s_mkdir - /var/lib/locales/supported.d/local20160608-22855-1nxbc2h.lock at 184:/etc/puppet/code/environments/production/modules/locales/manifests/init.pp
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.