summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Elrod <rick@elrod.me>2021-09-17 14:58:17 -0500
committerGitHub <noreply@github.com>2021-09-17 14:58:17 -0500
commit61f5c225510ca82ed43582540c9b9570ef676d7f (patch)
tree0dfd8cd6b7d439eca82e956ae06945d4af022eb2
parent1353678f237ee4ceb7345f6e277138aaa2af8db9 (diff)
downloadansible-61f5c225510ca82ed43582540c9b9570ef676d7f.tar.gz
Remove (only) user-facing use of ANSIBLE_ASYNC_DIR (#74249)
Change: - Remove only user-facing use of ANSIBLE_ASYNC_DIR. - Remove two comments saying to change things that, apparently, we aren't going to change... Test Plan: - ci_complete Tickets: - Fixes #74139 - Fixes #74138 - Refs #74226 Signed-off-by: Rick Elrod <rick@elrod.me>
-rw-r--r--changelogs/fragments/deprecate-ansible-async-dir-envvar.yml2
-rw-r--r--docs/docsite/rst/porting_guides/porting_guide_core_2.12.rst13
-rw-r--r--lib/ansible/plugins/action/__init__.py24
-rw-r--r--lib/ansible/plugins/action/async_status.py11
-rw-r--r--test/integration/targets/async/tasks/main.yml28
-rw-r--r--test/sanity/ignore.txt2
6 files changed, 18 insertions, 62 deletions
diff --git a/changelogs/fragments/deprecate-ansible-async-dir-envvar.yml b/changelogs/fragments/deprecate-ansible-async-dir-envvar.yml
new file mode 100644
index 0000000000..906ad9d331
--- /dev/null
+++ b/changelogs/fragments/deprecate-ansible-async-dir-envvar.yml
@@ -0,0 +1,2 @@
+minor_changes:
+ - "async tasks - the use of the task-level ``ANSIBLE_ASYNC_DIR`` variable within ``environment:`` is no longer valid. Use the shell configuration variable ``async_dir`` instead."
diff --git a/docs/docsite/rst/porting_guides/porting_guide_core_2.12.rst b/docs/docsite/rst/porting_guides/porting_guide_core_2.12.rst
index cc83f49c97..3961a553e2 100644
--- a/docs/docsite/rst/porting_guides/porting_guide_core_2.12.rst
+++ b/docs/docsite/rst/porting_guides/porting_guide_core_2.12.rst
@@ -19,7 +19,18 @@ This document is part of a collection on porting. The complete list of porting g
Playbook
========
-No notable changes
+* When calling tasks and setting ``async``, setting ``ANSIBLE_ASYNC_DIR`` under ``environment:`` is no longer valid. Instead, use the shell configuration variable ``async_dir``, for example by setting ``ansible_async_dir``:
+
+.. code-block:: yaml
+
+ tasks:
+ - dnf:
+ name: '*'
+ state: latest
+ async: 300
+ poll: 5
+ vars:
+ ansible_async_dir: /path/to/my/custom/dir
Python Interpreter Discovery
============================
diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py
index c071157b74..a2284bb020 100644
--- a/lib/ansible/plugins/action/__init__.py
+++ b/lib/ansible/plugins/action/__init__.py
@@ -984,25 +984,11 @@ class ActionBase(with_metaclass(ABCMeta, object)):
self._update_module_args(module_name, module_args, task_vars)
- # FIXME: convert async_wrapper.py to not rely on environment variables
- # make sure we get the right async_dir variable, backwards compatibility
- # means we need to lookup the env value ANSIBLE_ASYNC_DIR first
remove_async_dir = None
if wrap_async or self._task.async_val:
- env_async_dir = [e for e in self._task.environment if
- "ANSIBLE_ASYNC_DIR" in e]
- if len(env_async_dir) > 0:
- 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", collection_name='ansible.builtin')
- else:
- # ANSIBLE_ASYNC_DIR is not set on the task, we get the value
- # from the shell option and temporarily add to the environment
- # list for async_wrapper to pick up
- async_dir = self.get_shell_option('async_dir', default="~/.ansible_async")
- remove_async_dir = len(self._task.environment)
- self._task.environment.append({"ANSIBLE_ASYNC_DIR": async_dir})
+ async_dir = self.get_shell_option('async_dir', default="~/.ansible_async")
+ remove_async_dir = len(self._task.environment)
+ self._task.environment.append({"ANSIBLE_ASYNC_DIR": async_dir})
# FUTURE: refactor this along with module build process to better encapsulate "smart wrapper" functionality
(module_style, shebang, module_data, module_path) = self._configure_module(module_name=module_name, module_args=module_args, task_vars=task_vars)
@@ -1047,8 +1033,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
environment_string = self._compute_environment_string()
# remove the ANSIBLE_ASYNC_DIR env entry if we added a temporary one for
- # the async_wrapper task - this is so the async_status plugin doesn't
- # fire a deprecation warning when it runs after this task
+ # the async_wrapper task.
if remove_async_dir is not None:
del self._task.environment[remove_async_dir]
@@ -1077,7 +1062,6 @@ class ActionBase(with_metaclass(ABCMeta, object)):
# call the interpreter for async_wrapper directly
# this permits use of a script for an interpreter on non-Linux platforms
- # TODO: re-implement async_wrapper as a regular module to avoid this special case
interpreter = shebang.replace('#!', '').strip()
async_cmd = [interpreter, remote_async_module_path, async_jid, async_limit, remote_module_path]
diff --git a/lib/ansible/plugins/action/async_status.py b/lib/ansible/plugins/action/async_status.py
index b6cf9ec9e2..fc48716f7e 100644
--- a/lib/ansible/plugins/action/async_status.py
+++ b/lib/ansible/plugins/action/async_status.py
@@ -18,17 +18,6 @@ class ActionModule(ActionBase):
# async directory based on the shell option
async_dir = self.get_shell_option('async_dir', default="~/.ansible_async")
- # 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
- env_async_dir = [e for e in self._task.environment if "ANSIBLE_ASYNC_DIR" in e]
- if len(env_async_dir) > 0:
- 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", collection_name='ansible.builtin')
-
return self._remote_expand_user(async_dir)
def run(self, tmp=None, task_vars=None):
diff --git a/test/integration/targets/async/tasks/main.yml b/test/integration/targets/async/tasks/main.yml
index 255e7104ae..05c789e6c9 100644
--- a/test/integration/targets/async/tasks/main.yml
+++ b/test/integration/targets/async/tasks/main.yml
@@ -244,26 +244,6 @@
path: '{{ custom_async_tmp }}'
state: absent
- - name: run async task with custom dir - deprecated format
- command: sleep 1
- register: async_custom_dir_dep
- async: 5
- poll: 1
- environment:
- ANSIBLE_ASYNC_DIR: '{{ custom_async_tmp }}'
-
- - name: check if the async temp dir is created - deprecated format
- stat:
- path: '{{ custom_async_tmp }}'
- register: async_custom_dir_dep_result
-
- - name: assert run async task with custom dir - deprecated format
- assert:
- that:
- - async_custom_dir_dep is successful
- - async_custom_dir_dep is finished
- - async_custom_dir_dep_result.stat.exists
-
- name: remove custom async dir after deprecation test
file:
path: '{{ custom_async_tmp }}'
@@ -290,13 +270,6 @@
vars:
ansible_async_dir: '{{ custom_async_tmp }}'
- - name: get async status with custom dir - deprecated format
- async_status:
- jid: '{{ async_fandf_custom_dir.ansible_job_id }}'
- register: async_fandf_custom_dir_dep_result
- environment:
- ANSIBLE_ASYNC_DIR: '{{ custom_async_tmp }}'
-
- name: assert run fire and forget async task with custom dir
assert:
that:
@@ -304,7 +277,6 @@
- async_fandf_custom_dir_fail is failed
- async_fandf_custom_dir_fail.msg == "could not find job"
- async_fandf_custom_dir_result is successful
- - async_fandf_custom_dir_dep_result is successful
always:
- name: remove custom tmp dir after test
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 37cbb3117f..1b3fe15ff4 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -122,8 +122,6 @@ lib/ansible/plugins/shell/cmd.py pylint:arguments-renamed
lib/ansible/playbook/base.py pylint:disallowed-name
lib/ansible/playbook/collectionsearch.py required-and-default-attributes # https://github.com/ansible/ansible/issues/61460
lib/ansible/playbook/helpers.py pylint:disallowed-name
-lib/ansible/plugins/action/__init__.py pylint:ansible-deprecated-version
-lib/ansible/plugins/action/async_status.py pylint:ansible-deprecated-version
lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin
lib/ansible/plugins/cache/base.py ansible-doc!skip # not a plugin, but a stub for backwards compatibility
lib/ansible/plugins/lookup/sequence.py pylint:disallowed-name