-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
service_facts: Use LANG=C to run commands #44474
Conversation
The test
|
be6a123
to
f9abdb4
Compare
ready_for_review |
@@ -89,7 +91,8 @@ def gather_services(self): | |||
|
|||
# sysvinit | |||
if service_path is not None and chkconfig_path is None: | |||
rc, stdout, stderr = self.module.run_command("%s --status-all 2>&1 | grep -E \"\\[ (\\+|\\-) \\]\"" % service_path, use_unsafe_shell=True) | |||
rc, stdout, stderr = self.module.run_command( | |||
"%s --status-all 2>&1 | grep -E \"\\[ (\\+|\\-) \\]\"" % service_path, use_unsafe_shell=True, environ_update=LANG_C) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of updating each command just set run_command_environ_update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, I changed this and also added LC_ALL to the override. When I understand man 7 locale
correctly, only setting LC_ALL
should suffice since it has the highest priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
man page says that .. but not all programs obey that, though i think all the ones related to services do.
This allows to parse the output when the user's locale changes the commands' output. For example chkconfig uses 'Ein' and 'Aus' instead of 'on' and 'off' when using LANG=de_DE.UTF-8 breaking the service detection on RHEL 6.
f9abdb4
to
b5e3c5d
Compare
ready_for_review |
SUMMARY
This allows to parse the output when the user's locale changes the
commands' output. For example chkconfig uses 'Ein' and 'Aus' instead of
'on' and 'off' when using LANG=de_DE.UTF-8 breaking the service
detection on RHEL 6.
ISSUE TYPE
COMPONENT NAME
service_facts
ANSIBLE VERSION
ADDITIONAL INFORMATION