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 issue
This commit is contained in:
Jordan Borean 2018-09-20 19:37:54 +10:00 committed by GitHub
commit 5c73d4f4bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 269 additions and 19 deletions

View file

@ -177,3 +177,108 @@
- non_async_result is changed
- non_async_result is finished
- "'ansible_job_id' not in non_async_result"
- name: set fact of custom tmp dir
set_fact:
custom_async_tmp: ~/.ansible_async_test
- name: ensure custom async tmp dir is absent
file:
path: '{{ custom_async_tmp }}'
state: absent
- block:
- name: run async task with custom dir
command: sleep 1
register: async_custom_dir
async: 5
poll: 1
vars:
ansible_async_dir: '{{ custom_async_tmp }}'
- name: check if the async temp dir is created
stat:
path: '{{ custom_async_tmp }}'
register: async_custom_dir_result
- name: assert run async task with custom dir
assert:
that:
- async_custom_dir is successful
- async_custom_dir is finished
- async_custom_dir_result.stat.exists
- name: remove custom async dir again
file:
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 }}'
state: absent
- name: run fire and forget async task with custom dir
command: sleep 1
register: async_fandf_custom_dir
async: 5
poll: 0
vars:
ansible_async_dir: '{{ custom_async_tmp }}'
- name: fail to get async status with custom dir with defaults
async_status:
jid: '{{ async_fandf_custom_dir.ansible_job_id }}'
register: async_fandf_custom_dir_fail
ignore_errors: yes
- name: get async status with custom dir using newer format
async_status:
jid: '{{ async_fandf_custom_dir.ansible_job_id }}'
register: async_fandf_custom_dir_result
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:
- async_fandf_custom_dir is successful
- 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_result is finished
- async_fandf_custom_dir_dep_result is successful
- async_fandf_custom_dir_dep_result is finished
always:
- name: remove custom tmp dir after test
file:
path: '{{ custom_async_tmp }}'
state: absent