mirror of https://github.com/ansible/ansible.git
async: use async_dir for the async results file directory (#45461)
* win async: use async_dir for the async results file directory * tried to unify POSIX and PowerShell async implementations of async_dir * fix sanity issuepull/45942/head
parent
60979a96a9
commit
5c73d4f4bd
@ -0,0 +1,7 @@
|
||||
minor_changes:
|
||||
- windows async - change default directory from ``$env:TEMP\.ansible_async`` to ``$env:USERPROFILE\.ansible_async`` to match the POSIX standard.
|
||||
- windows async - async directory is now controlled by the ``async_dir`` shell option and not ``remote_tmp`` to match the POSIX standard.
|
||||
bugfixes:
|
||||
- async - fixed issue where the shell option ``async_dir`` was not being used when setting the async directory.
|
||||
deprecated_features:
|
||||
- async - setting the async directory using ``ANSIBLE_ASYNC_DIR`` as an environment key in a task or play is deprecated and will be removed in Ansible 2.12. Set a var name ``ansible_async_dir`` instead.
|
@ -0,0 +1,51 @@
|
||||
# Copyright: (c) 2018, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.utils.vars import merge_hash
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
_VALID_ARGS = frozenset(('jid', 'mode'))
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
results = super(ActionModule, self).run(tmp, task_vars)
|
||||
del tmp # tmp no longer has any effect
|
||||
|
||||
if "jid" not in self._task.args:
|
||||
raise AnsibleError("jid is required")
|
||||
jid = self._task.args["jid"]
|
||||
mode = self._task.args.get("mode", "status")
|
||||
|
||||
env_async_dir = [e for e in self._task.environment if
|
||||
"ANSIBLE_ASYNC_DIR" in e]
|
||||
if len(env_async_dir) > 0:
|
||||
# for backwards compatibility we need to get the dir from
|
||||
# ANSIBLE_ASYNC_DIR that is defined in the environment. This is
|
||||
# deprecated and will be removed in favour of shell options
|
||||
async_dir = env_async_dir[0]['ANSIBLE_ASYNC_DIR']
|
||||
|
||||
msg = "Setting the async dir from the environment keyword " \
|
||||
"ANSIBLE_ASYNC_DIR is deprecated. Set the async_dir " \
|
||||
"shell option instead"
|
||||
self._display.deprecated(msg, "2.12")
|
||||
else:
|
||||
# inject the async directory based on the shell option into the
|
||||
# module args
|
||||
try:
|
||||
async_dir = self._connection._shell.get_option('async_dir')
|
||||
except KeyError:
|
||||
# here for 3rd party shell plugin compatibility in case they do
|
||||
# not define the async_dir option
|
||||
async_dir = "~/.ansible_async"
|
||||
|
||||
module_args = dict(jid=jid, mode=mode, _async_dir=async_dir)
|
||||
status = self._execute_module(task_vars=task_vars,
|
||||
module_args=module_args)
|
||||
results = merge_hash(results, status)
|
||||
return results
|
Loading…
Reference in New Issue