mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
Temporary (#31677)
* allow shells to have per host options, remote_tmp added language to shell removed module lang setting from general as plugins have it now use get to avoid bad powershell plugin more resilient tmp discovery, fall back to `pwd` add shell to docs fixed options for when frags are only options added shell set ops in t_e and fixed option frags normalize tmp dir usag4e - pass tmpdir/tmp/temp options as env var to commands, making it default for tempfile - adjusted ansiballz tmpdir - default local tempfile usage to the configured local tmp - set env temp in action add options to powershell shift temporary to internal envvar/params ensure tempdir is set if we pass var ensure basic and url use expected tempdir ensure localhost uses local tmp give /var/tmp priority, less perms issues more consistent tempfile mgmt for ansiballz made async_dir configurable better action handling, allow for finally rm tmp fixed tmp issue and no more tempdir in ballz hostvarize world readable and admin users always set shell tempdir added comment to discourage use of exception/flow control * Mostly revert expand_user as it's not quite working. This was an additional feature anyhow. Kept the use of pwd as a fallback but moved it to a second ssh connection. This is not optimal but getting that to work in a single ssh connection was part of the problem holding this up. (cherry picked from commit 395b714120522f15e4c90a346f5e8e8d79213aca) * fixed script and other action plugins ensure tmpdir deletion allow for connections that don't support new options (legacy, 3rd party) fixed tests
This commit is contained in:
parent
eca3fcd214
commit
bbd6b8bb42
44 changed files with 1010 additions and 972 deletions
|
@ -37,9 +37,25 @@ FILE_ATTRIBUTES = {
|
|||
'Z': 'compresseddirty',
|
||||
}
|
||||
|
||||
# ansible modules can be written in any language. To simplify
|
||||
# development of Python modules, the functions available here can
|
||||
# be used to do many common tasks
|
||||
PASS_VARS = {
|
||||
'check_mode': 'check_mode',
|
||||
'debug': '_debug',
|
||||
'diff': '_diff',
|
||||
'module_name': '_name',
|
||||
'no_log': 'no_log',
|
||||
'selinux_special_fs': '_selinux_special_fs',
|
||||
'shell_executable': '_shell',
|
||||
'socket': '_socket_path',
|
||||
'syslog_facility': '_syslog_facility',
|
||||
'verbosity': '_verbosity',
|
||||
'version': 'ansible_version',
|
||||
}
|
||||
|
||||
PASS_BOOLS = ('no_log', 'debug', 'diff')
|
||||
|
||||
# Ansible modules can be written in any language.
|
||||
# The functions available here can be used to do many common tasks,
|
||||
# to simplify development of Python modules.
|
||||
|
||||
import locale
|
||||
import os
|
||||
|
@ -90,7 +106,7 @@ NoneType = type(None)
|
|||
try:
|
||||
from collections.abc import KeysView
|
||||
SEQUENCETYPE = (Sequence, frozenset, KeysView)
|
||||
except:
|
||||
except ImportError:
|
||||
SEQUENCETYPE = (Sequence, frozenset)
|
||||
|
||||
try:
|
||||
|
@ -826,11 +842,12 @@ class AnsibleModule(object):
|
|||
self._clean = {}
|
||||
|
||||
self.aliases = {}
|
||||
self._legal_inputs = ['_ansible_check_mode', '_ansible_no_log', '_ansible_debug', '_ansible_diff', '_ansible_verbosity',
|
||||
'_ansible_selinux_special_fs', '_ansible_module_name', '_ansible_version', '_ansible_syslog_facility',
|
||||
'_ansible_socket', '_ansible_shell_executable']
|
||||
self._legal_inputs = ['_ansible_%s' % k for k in PASS_VARS]
|
||||
self._options_context = list()
|
||||
|
||||
# set tempdir to remote tmp
|
||||
self.tempdir = os.environ.get('ANSIBLE_REMOTE_TEMP', None)
|
||||
|
||||
if add_file_common_args:
|
||||
for k, v in FILE_COMMON_ARGUMENTS.items():
|
||||
if k not in self.argument_spec:
|
||||
|
@ -1634,44 +1651,17 @@ class AnsibleModule(object):
|
|||
|
||||
for (k, v) in list(param.items()):
|
||||
|
||||
if k == '_ansible_check_mode' and v:
|
||||
self.check_mode = True
|
||||
|
||||
elif k == '_ansible_no_log':
|
||||
self.no_log = self.boolean(v)
|
||||
|
||||
elif k == '_ansible_debug':
|
||||
self._debug = self.boolean(v)
|
||||
|
||||
elif k == '_ansible_diff':
|
||||
self._diff = self.boolean(v)
|
||||
|
||||
elif k == '_ansible_verbosity':
|
||||
self._verbosity = v
|
||||
|
||||
elif k == '_ansible_selinux_special_fs':
|
||||
self._selinux_special_fs = v
|
||||
|
||||
elif k == '_ansible_syslog_facility':
|
||||
self._syslog_facility = v
|
||||
|
||||
elif k == '_ansible_version':
|
||||
self.ansible_version = v
|
||||
|
||||
elif k == '_ansible_module_name':
|
||||
self._name = v
|
||||
|
||||
elif k == '_ansible_socket':
|
||||
self._socket_path = v
|
||||
|
||||
elif k == '_ansible_shell_executable' and v:
|
||||
self._shell = v
|
||||
|
||||
elif check_invalid_arguments and k not in legal_inputs:
|
||||
if check_invalid_arguments and k not in legal_inputs:
|
||||
unsupported_parameters.add(k)
|
||||
elif k.startswith('_ansible_'):
|
||||
# handle setting internal properties from internal ansible vars
|
||||
key = k.replace('_ansible_', '')
|
||||
if key in PASS_BOOLS:
|
||||
setattr(self, PASS_VARS[key], self.boolean(v))
|
||||
else:
|
||||
setattr(self, PASS_VARS[key], v)
|
||||
|
||||
# clean up internal params:
|
||||
if k.startswith('_ansible_'):
|
||||
# clean up internal params:
|
||||
del self.params[k]
|
||||
|
||||
if unsupported_parameters:
|
||||
|
@ -2202,7 +2192,7 @@ class AnsibleModule(object):
|
|||
except:
|
||||
# we don't have access to the cwd, probably because of sudo.
|
||||
# Try and move to a neutral location to prevent errors
|
||||
for cwd in [os.path.expandvars('$HOME'), tempfile.gettempdir()]:
|
||||
for cwd in [self.tempdir, os.path.expandvars('$HOME'), tempfile.gettempdir()]:
|
||||
try:
|
||||
if os.access(cwd, os.F_OK | os.R_OK):
|
||||
os.chdir(cwd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue