mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Move module_set_locale and module_lang back to global
These config settings are being deprecated so we don't want people to think they need to implement them for their new shell plugin.
This commit is contained in:
parent
62bc714dae
commit
b151f5d942
4 changed files with 35 additions and 36 deletions
|
@ -744,6 +744,19 @@ DEFAULT_MODULE_COMPRESSION:
|
||||||
- {key: module_compression, section: defaults}
|
- {key: module_compression, section: defaults}
|
||||||
# vars:
|
# vars:
|
||||||
# - name: ansible_module_compression
|
# - name: ansible_module_compression
|
||||||
|
DEFAULT_MODULE_LANG:
|
||||||
|
name: Target language environment
|
||||||
|
default: "{{ CONTROLLER_LANG }}"
|
||||||
|
description:
|
||||||
|
- "Language locale setting to use for modules when they execute on the target."
|
||||||
|
- "If empty it tries to set itself to the LANG environment variable on the controller."
|
||||||
|
- "This is only used if DEFAULT_MODULE_SET_LOCALE is set to true"
|
||||||
|
env: [{name: ANSIBLE_MODULE_LANG}]
|
||||||
|
ini:
|
||||||
|
- {key: module_lang, section: defaults}
|
||||||
|
deprecated:
|
||||||
|
why: Modules are coded to set their own locale if needed for screenscraping
|
||||||
|
version: "2.9"
|
||||||
DEFAULT_MODULE_NAME:
|
DEFAULT_MODULE_NAME:
|
||||||
name: Default adhoc module
|
name: Default adhoc module
|
||||||
default: command
|
default: command
|
||||||
|
@ -759,6 +772,18 @@ DEFAULT_MODULE_PATH:
|
||||||
ini:
|
ini:
|
||||||
- {key: library, section: defaults}
|
- {key: library, section: defaults}
|
||||||
type: pathspec
|
type: pathspec
|
||||||
|
DEFAULT_MODULE_SET_LOCALE:
|
||||||
|
name: Target locale
|
||||||
|
default: False
|
||||||
|
description:
|
||||||
|
- Controls if we set locale for modules when executing on the target.
|
||||||
|
env: [{name: ANSIBLE_MODULE_SET_LOCALE}]
|
||||||
|
ini:
|
||||||
|
- {key: module_set_locale, section: defaults}
|
||||||
|
type: boolean
|
||||||
|
deprecated:
|
||||||
|
why: Modules are coded to set their own locale if needed for screenscraping
|
||||||
|
version: "2.9"
|
||||||
DEFAULT_MODULE_UTILS_PATH:
|
DEFAULT_MODULE_UTILS_PATH:
|
||||||
name: Module Utils Path
|
name: Module Utils Path
|
||||||
description: Colon separated paths in which Ansible will search for Module utils files, which are shared by modules.
|
description: Colon separated paths in which Ansible will search for Module utils files, which are shared by modules.
|
||||||
|
|
|
@ -17,14 +17,14 @@ from ansible.module_utils.six import string_types
|
||||||
from ansible.config.manager import ConfigManager, ensure_type, get_ini_config_value
|
from ansible.config.manager import ConfigManager, ensure_type, get_ini_config_value
|
||||||
|
|
||||||
|
|
||||||
def _deprecated(msg):
|
def _deprecated(msg, version='2.8'):
|
||||||
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
|
''' display is not guaranteed here, nor it being the full class, but try anyways, fallback to sys.stderr.write '''
|
||||||
try:
|
try:
|
||||||
from __main__ import display
|
from __main__ import display
|
||||||
display.deprecated(msg, version='2.8')
|
display.deprecated(msg, version=version)
|
||||||
except:
|
except:
|
||||||
import sys
|
import sys
|
||||||
sys.stderr.write('[DEPRECATED] %s, to be removed in 2.8' % msg)
|
sys.stderr.write('[DEPRECATED] %s, to be removed in %s' % (msg, version))
|
||||||
|
|
||||||
|
|
||||||
def mk_boolean(value):
|
def mk_boolean(value):
|
||||||
|
|
|
@ -23,6 +23,7 @@ import random
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import ansible.constants as C
|
||||||
from ansible.module_utils.six import text_type
|
from ansible.module_utils.six import text_type
|
||||||
from ansible.module_utils.six.moves import shlex_quote
|
from ansible.module_utils.six.moves import shlex_quote
|
||||||
from ansible.plugins import AnsiblePlugin
|
from ansible.plugins import AnsiblePlugin
|
||||||
|
@ -36,22 +37,18 @@ class ShellBase(AnsiblePlugin):
|
||||||
super(ShellBase, self).__init__()
|
super(ShellBase, self).__init__()
|
||||||
|
|
||||||
self.env = {}
|
self.env = {}
|
||||||
|
if C.DEFAULT_MODULE_SET_LOCALE:
|
||||||
|
module_locale = C.DEFAULT_MODULE_LANG
|
||||||
|
self.env = {'LANG': module_locale,
|
||||||
|
'LC_ALL': module_locale,
|
||||||
|
'LC_MESSAGES': module_locale}
|
||||||
|
|
||||||
self.tempdir = None
|
self.tempdir = None
|
||||||
|
|
||||||
def set_options(self, task_keys=None, var_options=None, direct=None):
|
def set_options(self, task_keys=None, var_options=None, direct=None):
|
||||||
|
|
||||||
super(ShellBase, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
|
super(ShellBase, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
|
||||||
|
|
||||||
# not all shell modules have this option
|
|
||||||
if self.get_option('set_module_language'):
|
|
||||||
self.env.update(
|
|
||||||
dict(
|
|
||||||
LANG=self.get_option('module_language'),
|
|
||||||
LC_ALL=self.get_option('module_language'),
|
|
||||||
LC_MESSAGES=self.get_option('module_language'),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# set env
|
# set env
|
||||||
self.env.update(self.get_option('environment'))
|
self.env.update(self.get_option('environment'))
|
||||||
|
|
||||||
|
|
|
@ -38,29 +38,6 @@ options:
|
||||||
key: async_dir
|
key: async_dir
|
||||||
vars:
|
vars:
|
||||||
- name: ansible_async_dir
|
- name: ansible_async_dir
|
||||||
set_module_language:
|
|
||||||
default: False
|
|
||||||
description: Controls if we set locale for modules when executing on the target.
|
|
||||||
env:
|
|
||||||
- name: ANSIBLE_MODULE_SET_LOCALE
|
|
||||||
ini:
|
|
||||||
- section: defaults
|
|
||||||
key: module_set_locale
|
|
||||||
type: boolean
|
|
||||||
vars:
|
|
||||||
- name: ansible_module_set_locale
|
|
||||||
module_language:
|
|
||||||
description:
|
|
||||||
- "If 'set_module_language' is true, this is the language language/locale setting to use for modules when they execute on the target."
|
|
||||||
- "Defaults to match the controller's settings."
|
|
||||||
default: "{{CONTROLLER_LANG}}"
|
|
||||||
env:
|
|
||||||
- name: ANSIBLE_MODULE_LANG
|
|
||||||
ini:
|
|
||||||
- section: defaults
|
|
||||||
key: module_lang
|
|
||||||
vars:
|
|
||||||
- name: ansible_module_lang
|
|
||||||
environment:
|
environment:
|
||||||
type: dict
|
type: dict
|
||||||
default: {}
|
default: {}
|
||||||
|
|
Loading…
Reference in a new issue