From 7c43cc3faa51bfb873e5c2a6336478f9594f14de Mon Sep 17 00:00:00 2001
From: Felix Fontein <felix@fontein.de>
Date: Thu, 9 Sep 2021 07:31:44 +0200
Subject: [PATCH] Improve CI (#3348)

* Remove superfluous test.

* Use remote_temp_dir instead of output_dir on remote.

* Read certificate from correct place.

* Adjust more places.

* Fix boolean.

* Improve cryptography setup.

* Fix java_keystore changes.

* Need to copy binary from remote.

* Use correct Python for serve script.

* Sleep before downloading.

* Use correct Python interpreter.

* Avoid failing shebang test.

* Fix permission error with macOS 11.1.

* Avoid shebang trouble.
---
 .../ansible_galaxy_install/meta/main.yml      |   2 +
 .../ansible_galaxy_install/tasks/main.yml     |   2 +-
 .../integration/targets/archive/meta/main.yml |   1 +
 .../targets/archive/tasks/main.yml            |   2 +-
 .../targets/archive/tests/broken-link.yml     |  12 +-
 .../targets/archive/tests/core.yml            |  58 ++++----
 .../targets/archive/tests/exclusions.yml      |  18 +--
 .../targets/archive/tests/idempotency.yml     |  56 ++++----
 .../targets/archive/tests/remove.yml          |  70 +++++-----
 .../integration/targets/consul/meta/main.yml  |   1 +
 .../integration/targets/consul/tasks/main.yml |  28 ++--
 .../targets/deploy_helper/meta/main.yml       |   2 +
 .../targets/deploy_helper/tasks/main.yml      |   2 +-
 .../targets/filter_random_mac/meta/main.yml   |   2 +
 .../targets/filter_random_mac/tasks/main.yml  |   3 -
 .../targets/flatpak/tasks/setup.yml           |   2 +-
 tests/integration/targets/gem/meta/main.yml   |   1 +
 tests/integration/targets/gem/tasks/main.yml  |  18 +--
 .../targets/git_config/meta/main.yml          |   2 +
 .../tasks/get_set_state_present_file.yml      |   5 +-
 .../git_config/tasks/setup_no_value.yml       |   3 +-
 .../targets/git_config/tasks/setup_value.yml  |   3 +-
 tests/integration/targets/hg/meta/main.yml    |   1 +
 .../targets/hg/tasks/run-tests.yml            |   6 +-
 .../targets/iso_create/meta/main.yml          |   1 +
 .../targets/iso_create/tasks/main.yml         |  54 ++++----
 .../iso_create/tasks/prepare_dest_dir.yml     |   4 +-
 .../targets/iso_extract/meta/main.yml         |   1 +
 .../targets/iso_extract/tasks/main.yml        |   2 +-
 .../targets/iso_extract/tasks/prepare.yml     |   6 +-
 .../targets/iso_extract/tasks/tests.yml       |   8 +-
 .../targets/java_cert/defaults/main.yml       |  18 +--
 .../targets/java_cert/meta/main.yml           |   1 +
 .../targets/java_cert/tasks/main.yml          |  22 +--
 .../targets/java_cert/tasks/state_change.yml  |   8 +-
 .../targets/java_keystore/meta/main.yml       |   1 +
 .../targets/java_keystore/tasks/prepare.yml   |  14 +-
 .../targets/java_keystore/tasks/tests.yml     | 128 ++++++++++++++----
 tests/integration/targets/mail/meta/main.yml  |   2 +
 tests/integration/targets/mail/tasks/main.yml |   4 +-
 tests/integration/targets/nomad/meta/main.yml |   1 +
 .../integration/targets/nomad/tasks/main.yml  |  22 +--
 tests/integration/targets/npm/meta/main.yml   |   1 +
 tests/integration/targets/npm/tasks/main.yml  |   2 +-
 tests/integration/targets/npm/tasks/setup.yml |   4 +-
 tests/integration/targets/pids/meta/main.yml  |   2 +
 tests/integration/targets/pids/tasks/main.yml |  18 ++-
 .../targets/setup_openssl/tasks/main.yml      |  21 +++
 .../targets/setup_openssl/vars/Debian.yml     |   2 +
 .../targets/setup_openssl/vars/FreeBSD.yml    |   2 +
 .../targets/setup_openssl/vars/RedHat.yml     |   2 +
 .../targets/setup_openssl/vars/Suse.yml       |   2 +
 .../targets/ssh_config/meta/main.yml          |   1 +
 .../targets/ssh_config/tasks/main.yml         |   8 +-
 .../targets/supervisorctl/meta/main.yml       |   1 +
 .../targets/supervisorctl/tasks/main.yml      |   2 +-
 .../targets/synchronize-buildah/aliases       |   3 -
 .../targets/synchronize-buildah/inventory     |   1 -
 .../files/normal_file.txt                     |   1 -
 .../test_buildah_synchronize/tasks/main.yml   |  71 ----------
 .../targets/synchronize-buildah/runme.sh      |  15 --
 .../test_synchronize_buildah.yml              |   8 --
 .../targets/xattr/defaults/main.yml           |   2 +-
 tests/integration/targets/xattr/meta/main.yml |   1 +
 tests/integration/targets/yarn/meta/main.yml  |   1 +
 tests/integration/targets/yarn/tasks/run.yml  |  28 ++--
 .../integration/targets/zypper/meta/main.yml  |   2 +
 .../targets/zypper/tasks/zypper.yml           |  36 ++---
 68 files changed, 440 insertions(+), 394 deletions(-)
 create mode 100644 tests/integration/targets/ansible_galaxy_install/meta/main.yml
 create mode 100644 tests/integration/targets/deploy_helper/meta/main.yml
 create mode 100644 tests/integration/targets/filter_random_mac/meta/main.yml
 create mode 100644 tests/integration/targets/git_config/meta/main.yml
 create mode 100644 tests/integration/targets/mail/meta/main.yml
 create mode 100644 tests/integration/targets/pids/meta/main.yml
 delete mode 100644 tests/integration/targets/synchronize-buildah/aliases
 delete mode 100644 tests/integration/targets/synchronize-buildah/inventory
 delete mode 100644 tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/files/normal_file.txt
 delete mode 100644 tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/tasks/main.yml
 delete mode 100644 tests/integration/targets/synchronize-buildah/runme.sh
 delete mode 100644 tests/integration/targets/synchronize-buildah/test_synchronize_buildah.yml
 create mode 100644 tests/integration/targets/zypper/meta/main.yml

diff --git a/tests/integration/targets/ansible_galaxy_install/meta/main.yml b/tests/integration/targets/ansible_galaxy_install/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/ansible_galaxy_install/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/ansible_galaxy_install/tasks/main.yml b/tests/integration/targets/ansible_galaxy_install/tasks/main.yml
index 232c96aff5..276dab3a30 100644
--- a/tests/integration/targets/ansible_galaxy_install/tasks/main.yml
+++ b/tests/integration/targets/ansible_galaxy_install/tasks/main.yml
@@ -50,7 +50,7 @@
 ###################################################
 - name:
   set_fact:
-    reqs_file: '{{ output_dir }}/reqs.yaml'
+    reqs_file: '{{ remote_tmp_dir }}/reqs.yaml'
 
 - name: Copy requirements file
   copy:
diff --git a/tests/integration/targets/archive/meta/main.yml b/tests/integration/targets/archive/meta/main.yml
index 5438ced5c3..56bc554611 100644
--- a/tests/integration/targets/archive/meta/main.yml
+++ b/tests/integration/targets/archive/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_pkg_mgr
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/archive/tasks/main.yml b/tests/integration/targets/archive/tasks/main.yml
index 1e2c9f9c27..e7b6c44175 100644
--- a/tests/integration/targets/archive/tasks/main.yml
+++ b/tests/integration/targets/archive/tasks/main.yml
@@ -75,7 +75,7 @@
   register: backports_lzma_pip
 
 - name: prep our files
-  copy: src={{ item }} dest={{output_dir}}/{{ item }}
+  copy: src={{ item }} dest={{remote_tmp_dir}}/{{ item }}
   with_items:
     - foo.txt
     - bar.txt
diff --git a/tests/integration/targets/archive/tests/broken-link.yml b/tests/integration/targets/archive/tests/broken-link.yml
index cc1e07aaf1..677ebe0bf7 100644
--- a/tests/integration/targets/archive/tests/broken-link.yml
+++ b/tests/integration/targets/archive/tests/broken-link.yml
@@ -3,29 +3,29 @@
     - name: Create link - broken link ({{ format }})
       file:
         src: /nowhere
-        dest: "{{ output_dir }}/nowhere.txt"
+        dest: "{{ remote_tmp_dir }}/nowhere.txt"
         state: link
         force: yes
 
     - name: Archive - broken link ({{ format }})
       archive:
-        path: "{{ output_dir }}/*.txt"
-        dest: "{{ output_dir }}/archive_broken_link.{{ format }}"
+        path: "{{ remote_tmp_dir }}/*.txt"
+        dest: "{{ remote_tmp_dir }}/archive_broken_link.{{ format }}"
         format: "{{ format }}"
 
     - name: Verify archive exists - broken link ({{ format }})
       file:
-        path: "{{ output_dir }}/archive_broken_link.{{ format }}"
+        path: "{{ remote_tmp_dir }}/archive_broken_link.{{ format }}"
         state: file
 
     - name: Remove archive - broken link ({{ format }})
       file:
-        path: "{{ output_dir }}/archive_broken_link.{{ format }}"
+        path: "{{ remote_tmp_dir }}/archive_broken_link.{{ format }}"
         state: absent
 
     - name: Remove link - broken link ({{ format }})
       file:
-        path: "{{ output_dir }}/nowhere.txt"
+        path: "{{ remote_tmp_dir }}/nowhere.txt"
         state: absent
   # 'zip' does not support symlink's
   when: format != 'zip'
diff --git a/tests/integration/targets/archive/tests/core.yml b/tests/integration/targets/archive/tests/core.yml
index d008e9c122..f3ae906429 100644
--- a/tests/integration/targets/archive/tests/core.yml
+++ b/tests/integration/targets/archive/tests/core.yml
@@ -25,14 +25,14 @@
 # Core functionality tests
 - name: Archive - no options ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_no_opts.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_no_opts.{{ format }}"
     format: "{{ format }}"
   register: archive_no_options
 
 - name: Verify that archive exists - no options ({{ format }})
   file:
-    path: "{{output_dir}}/archive_no_opts.{{ format }}"
+    path: "{{remote_tmp_dir}}/archive_no_opts.{{ format }}"
     state: file
 
 - name: Verify that archive result is changed and includes all files - no options ({{ format }})
@@ -44,20 +44,20 @@
 
 - name: Remove the archive - no options ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_no_options.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_no_options.{{ format }}"
     state: absent
 
 - name: Archive - file options ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_file_options.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_file_options.{{ format }}"
     format: "{{ format }}"
     mode: "u+rwX,g-rwx,o-rwx"
   register: archive_file_options
 
 - name: Retrieve archive file information - file options ({{ format }})
   stat:
-    path: "{{ output_dir }}/archive_file_options.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_file_options.{{ format }}"
   register: archive_file_options_stat
 
 - name: Test that the file modes were changed
@@ -69,19 +69,19 @@
 
 - name: Remove the archive - file options ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_file_options.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_file_options.{{ format }}"
     state: absent
 
 - name: Archive - non-ascii ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_nonascii_くらとみ.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_nonascii_くらとみ.{{ format }}"
     format: "{{ format }}"
   register: archive_nonascii
 
 - name: Retrieve archive file information - non-ascii ({{ format }})
   stat:
-    path: "{{ output_dir }}/archive_nonascii_くらとみ.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_nonascii_くらとみ.{{ format }}"
   register: archive_nonascii_stat
 
 - name: Test that archive exists - non-ascii ({{ format }})
@@ -92,13 +92,13 @@
 
 - name: Remove the archive - non-ascii ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_nonascii_くらとみ.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_nonascii_くらとみ.{{ format }}"
     state: absent
 
 - name: Archive - single target ({{ format }})
   archive:
-    path: "{{ output_dir }}/foo.txt"
-    dest: "{{ output_dir }}/archive_single_target.{{ format }}"
+    path: "{{ remote_tmp_dir }}/foo.txt"
+    dest: "{{ remote_tmp_dir }}/archive_single_target.{{ format }}"
     format: "{{ format }}"
   register: archive_single_target
 
@@ -117,7 +117,7 @@
 - block:
     - name: Retrieve contents of archive - single target ({{ format }})
       ansible.builtin.unarchive:
-        src: "{{ output_dir }}/archive_single_target.{{ format }}"
+        src: "{{ remote_tmp_dir }}/archive_single_target.{{ format }}"
         dest: .
         list_files: true
       check_mode: true
@@ -135,22 +135,22 @@
 
 - name: Remove archive - single target ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_single_target.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_single_target.{{ format }}"
     state: absent
 
 - name: Archive - path list ({{ format }})
   archive:
     path:
-      - "{{ output_dir }}/empty.txt"
-      - "{{ output_dir }}/foo.txt"
-      - "{{ output_dir }}/bar.txt"
-    dest: "{{ output_dir }}/archive_path_list.{{ format }}"
+      - "{{ remote_tmp_dir }}/empty.txt"
+      - "{{ remote_tmp_dir }}/foo.txt"
+      - "{{ remote_tmp_dir }}/bar.txt"
+    dest: "{{ remote_tmp_dir }}/archive_path_list.{{ format }}"
     format: "{{ format }}"
   register: archive_path_list
 
 - name: Verify that archive exists - path list ({{ format }})
   file:
-    path: "{{output_dir}}/archive_path_list.{{ format }}"
+    path: "{{remote_tmp_dir}}/archive_path_list.{{ format }}"
     state: file
 
 - name: Assert that archive contains all files - path list ({{ format }})
@@ -161,16 +161,16 @@
 
 - name: Remove archive - path list ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_path_list.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_path_list.{{ format }}"
     state: absent
 
 - name: Archive - missing paths ({{ format }})
   archive:
     path:
-      - "{{ output_dir }}/*.txt"
-      - "{{ output_dir }}/dne.txt"
-    exclude_path: "{{ output_dir }}/foo.txt"
-    dest: "{{ output_dir }}/archive_missing_paths.{{ format }}"
+      - "{{ remote_tmp_dir }}/*.txt"
+      - "{{ remote_tmp_dir }}/dne.txt"
+    exclude_path: "{{ remote_tmp_dir }}/foo.txt"
+    dest: "{{ remote_tmp_dir }}/archive_missing_paths.{{ format }}"
     format: "{{ format }}"
   register: archive_missing_paths
 
@@ -179,10 +179,10 @@
     that:
       - archive_missing_paths is changed
       - "archive_missing_paths.dest_state == 'incomplete'"
-      - "'{{ output_dir }}/dne.txt' in archive_missing_paths.missing"
-      - "'{{ output_dir }}/foo.txt' not in archive_missing_paths.missing"
+      - "'{{ remote_tmp_dir }}/dne.txt' in archive_missing_paths.missing"
+      - "'{{ remote_tmp_dir }}/foo.txt' not in archive_missing_paths.missing"
 
 - name: Remove archive - missing paths ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_missing_paths.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_missing_paths.{{ format }}"
     state: absent
diff --git a/tests/integration/targets/archive/tests/exclusions.yml b/tests/integration/targets/archive/tests/exclusions.yml
index 0b65f85851..b2a8c7b890 100644
--- a/tests/integration/targets/archive/tests/exclusions.yml
+++ b/tests/integration/targets/archive/tests/exclusions.yml
@@ -1,8 +1,8 @@
 ---
 - name: Archive - exclusion patterns ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_exclusion_patterns.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_exclusion_patterns.{{ format }}"
     format: "{{ format }}"
     exclusion_patterns: b?r.*
   register: archive_exclusion_patterns
@@ -15,26 +15,26 @@
 
 - name: Remove archive - exclusion patterns ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_exclusion_patterns.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_exclusion_patterns.{{ format }}"
     state: absent
 
 - name: Archive - exclude path ({{ format }})
   archive:
     path:
-      - "{{ output_dir }}/sub/subfile.txt"
-      - "{{ output_dir }}"
+      - "{{ remote_tmp_dir }}/sub/subfile.txt"
+      - "{{ remote_tmp_dir }}"
     exclude_path:
-      - "{{ output_dir }}"
-    dest: "{{ output_dir }}/archive_exclude_paths.{{ format }}"
+      - "{{ remote_tmp_dir }}"
+    dest: "{{ remote_tmp_dir }}/archive_exclude_paths.{{ format }}"
     format: "{{ format }}"
   register: archive_excluded_paths
 
 - name: Assert that excluded paths do not influence archive root - exclude path ({{ format }})
   assert:
     that:
-      - archive_excluded_paths.arcroot != output_dir
+      - archive_excluded_paths.arcroot != remote_tmp_dir
 
 - name: Remove archive - exclude path ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_exclude_paths.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_exclude_paths.{{ format }}"
     state: absent
diff --git a/tests/integration/targets/archive/tests/idempotency.yml b/tests/integration/targets/archive/tests/idempotency.yml
index 9262601572..5a44922adb 100644
--- a/tests/integration/targets/archive/tests/idempotency.yml
+++ b/tests/integration/targets/archive/tests/idempotency.yml
@@ -1,8 +1,8 @@
 ---
 - name: Archive - file content idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_file_content_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_file_content_idempotency.{{ format }}"
     format: "{{ format }}"
   register: file_content_idempotency_before
 
@@ -10,12 +10,12 @@
   lineinfile:
     line: bar.txt
     regexp: "^foo.txt$"
-    path: "{{ output_dir }}/foo.txt"
+    path: "{{ remote_tmp_dir }}/foo.txt"
 
 - name: Archive second time - file content idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_file_content_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_file_content_idempotency.{{ format }}"
     format: "{{ format }}"
   register: file_content_idempotency_after
 
@@ -28,29 +28,29 @@
 
 - name: Remove archive - file content idempotency ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_file_content_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_file_content_idempotency.{{ format }}"
     state: absent
 
 - name: Modify file back - file content idempotency ({{ format }})
   lineinfile:
     line: foo.txt
     regexp: "^bar.txt$"
-    path: "{{ output_dir }}/foo.txt"
+    path: "{{ remote_tmp_dir }}/foo.txt"
 
 - name: Archive - file name idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_file_name_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_file_name_idempotency.{{ format }}"
     format: "{{ format }}"
   register: file_name_idempotency_before
 
 - name: Rename file - file name idempotency ({{ format }})
-  command: "mv {{ output_dir}}/foo.txt {{ output_dir }}/fii.txt"
+  command: "mv {{ remote_tmp_dir }}/foo.txt {{ remote_tmp_dir }}/fii.txt"
 
 - name: Archive again - file name idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_file_name_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_file_name_idempotency.{{ format }}"
     format: "{{ format }}"
   register: file_name_idempotency_after
 
@@ -61,16 +61,16 @@
 
 - name: Remove archive - file name idempotency ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_file_name_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_file_name_idempotency.{{ format }}"
     state: absent
 
 - name: Rename file back - file name idempotency ({{ format }})
-  command: "mv {{ output_dir }}/fii.txt {{ output_dir }}/foo.txt"
+  command: "mv {{ remote_tmp_dir }}/fii.txt {{ remote_tmp_dir }}/foo.txt"
 
 - name: Archive - single file content idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/foo.txt"
-    dest: "{{ output_dir }}/archive_single_file_content_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/foo.txt"
+    dest: "{{ remote_tmp_dir }}/archive_single_file_content_idempotency.{{ format }}"
     format: "{{ format }}"
   register: single_file_content_idempotency_before
 
@@ -78,12 +78,12 @@
   lineinfile:
     line: bar.txt
     regexp: "^foo.txt$"
-    path: "{{ output_dir }}/foo.txt"
+    path: "{{ remote_tmp_dir }}/foo.txt"
 
 - name: Archive second time - single file content idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/foo.txt"
-    dest: "{{ output_dir }}/archive_single_file_content_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/foo.txt"
+    dest: "{{ remote_tmp_dir }}/archive_single_file_content_idempotency.{{ format }}"
     format: "{{ format }}"
   register: single_file_content_idempotency_after
 
@@ -96,29 +96,29 @@
 
 - name: Remove archive - single file content idempotency ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_single_file_content_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_single_file_content_idempotency.{{ format }}"
     state: absent
 
 - name: Modify file back - single file content idempotency ({{ format }})
   lineinfile:
     line: foo.txt
     regexp: "^bar.txt$"
-    path: "{{ output_dir }}/foo.txt"
+    path: "{{ remote_tmp_dir }}/foo.txt"
 
 - name: Archive - single file name idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/foo.txt"
-    dest: "{{ output_dir }}/archive_single_file_name_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/foo.txt"
+    dest: "{{ remote_tmp_dir }}/archive_single_file_name_idempotency.{{ format }}"
     format: "{{ format }}"
   register: single_file_name_idempotency_before
 
 - name: Rename file - single file name idempotency ({{ format }})
-  command: "mv {{ output_dir}}/foo.txt {{ output_dir }}/fii.txt"
+  command: "mv {{ remote_tmp_dir }}/foo.txt {{ remote_tmp_dir }}/fii.txt"
 
 - name: Archive again - single file name idempotency ({{ format }})
   archive:
-    path: "{{ output_dir }}/fii.txt"
-    dest: "{{ output_dir }}/archive_single_file_name_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/fii.txt"
+    dest: "{{ remote_tmp_dir }}/archive_single_file_name_idempotency.{{ format }}"
     format: "{{ format }}"
   register: single_file_name_idempotency_after
 
@@ -133,8 +133,8 @@
 
 - name: Remove archive - single file name idempotency ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_single_file_name_idempotency.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_single_file_name_idempotency.{{ format }}"
     state: absent
 
 - name: Rename file back - single file name idempotency ({{ format }})
-  command: "mv {{ output_dir }}/fii.txt {{ output_dir }}/foo.txt"
+  command: "mv {{ remote_tmp_dir }}/fii.txt {{ remote_tmp_dir }}/foo.txt"
diff --git a/tests/integration/targets/archive/tests/remove.yml b/tests/integration/targets/archive/tests/remove.yml
index 26849ac850..08f16e98da 100644
--- a/tests/integration/targets/archive/tests/remove.yml
+++ b/tests/integration/targets/archive/tests/remove.yml
@@ -1,15 +1,15 @@
 ---
 - name: Archive - remove source files ({{ format }})
   archive:
-    path: "{{ output_dir }}/*.txt"
-    dest: "{{ output_dir }}/archive_remove_source_files.{{ format }}"
+    path: "{{ remote_tmp_dir }}/*.txt"
+    dest: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}"
     format: "{{ format }}"
     remove: yes
   register: archive_remove_source_files
 
 - name: Verify archive exists - remove source files ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_files.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}"
     state: file
 
 - name: Verify all files were archived - remove source files ({{ format }})
@@ -20,13 +20,13 @@
 
 - name: Remove Archive - remove source files ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_files.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_files.{{ format }}"
     state: absent
 
 - name: Assert that source files were removed - remove source files ({{ format }})
   assert:
     that:
-      - "'{{ output_dir }}/{{ item }}' is not exists"
+      - "'{{ remote_tmp_dir }}/{{ item }}' is not exists"
   with_items:
     - foo.txt
     - bar.txt
@@ -35,7 +35,7 @@
 - name: Copy source files - remove source directory ({{ format }})
   copy:
     src: "{{ item }}"
-    dest: "{{ output_dir }}/{{ item }}"
+    dest: "{{ remote_tmp_dir }}/{{ item }}"
   with_items:
     - foo.txt
     - bar.txt
@@ -43,13 +43,13 @@
 
 - name: Create temporary directory - remove source directory ({{ format }})
   file:
-    path: "{{ output_dir }}/tmpdir"
+    path: "{{ remote_tmp_dir }}/tmpdir"
     state: directory
 
 - name: Copy source files to temporary directory - remove source directory ({{ format }})
   copy:
     src: "{{ item }}"
-    dest: "{{ output_dir }}/tmpdir/{{ item }}"
+    dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
   with_items:
     - foo.txt
     - bar.txt
@@ -57,15 +57,15 @@
 
 - name: Archive - remove source directory ({{ format }})
   archive:
-    path: "{{ output_dir }}/tmpdir"
-    dest: "{{ output_dir }}/archive_remove_source_directory.{{ format }}"
+    path: "{{ remote_tmp_dir }}/tmpdir"
+    dest: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}"
     format: "{{ format }}"
     remove: yes
   register: archive_remove_source_directory
 
 - name: Verify archive exists - remove source directory ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_directory.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}"
     state: file
 
 - name: Verify archive contains all files - remove source directory ({{ format }})
@@ -76,23 +76,23 @@
 
 - name: Remove archive - remove source directory ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_directory.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_directory.{{ format }}"
     state: absent
 
 - name: Verify source directory was removed - remove source directory ({{ format }})
   assert:
     that:
-      - "'{{ output_dir }}/tmpdir' is not exists"
+      - "'{{ remote_tmp_dir }}/tmpdir' is not exists"
 
 - name: Create temporary directory - remove source excluding path ({{ format }})
   file:
-    path: "{{ output_dir }}/tmpdir"
+    path: "{{ remote_tmp_dir }}/tmpdir"
     state: directory
 
 - name: Copy source files to temporary directory - remove source excluding path ({{ format }})
   copy:
     src: "{{ item }}"
-    dest: "{{ output_dir }}/tmpdir/{{ item }}"
+    dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
   with_items:
     - foo.txt
     - bar.txt
@@ -100,16 +100,16 @@
 
 - name: Archive - remove source excluding path ({{ format }})
   archive:
-    path: "{{ output_dir }}/tmpdir/*"
-    dest: "{{ output_dir }}/archive_remove_source_excluding_path.{{ format }}"
+    path: "{{ remote_tmp_dir }}/tmpdir/*"
+    dest: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}"
     format: "{{ format }}"
     remove: yes
-    exclude_path: "{{ output_dir }}/tmpdir/empty.txt"
+    exclude_path: "{{ remote_tmp_dir }}/tmpdir/empty.txt"
   register: archive_remove_source_excluding_path
 
 - name: Verify archive exists - remove source excluding path ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_excluding_path.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}"
     state: file
 
 - name: Verify all files except excluded are archived - remove source excluding path ({{ format }})
@@ -120,18 +120,18 @@
 
 - name: Remove archive - remove source excluding path ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_excluding_path.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_path.{{ format }}"
     state: absent
 
 - name: Verify that excluded file still exists - remove source excluding path ({{ format }})
   file:
-    path: "{{ output_dir }}/tmpdir/empty.txt"
+    path: "{{ remote_tmp_dir }}/tmpdir/empty.txt"
     state: file
 
 - name: Copy source files to temporary directory - remove source excluding sub path ({{ format }})
   copy:
     src: "{{ item }}"
-    dest: "{{ output_dir }}/tmpdir/{{ item }}"
+    dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
   with_items:
     - foo.txt
     - bar.txt
@@ -142,33 +142,33 @@
 - name: Archive - remove source excluding sub path ({{ format }})
   archive:
     path:
-      - "{{ output_dir }}/tmpdir/*.txt"
-      - "{{ output_dir }}/tmpdir/sub/*"
-    dest: "{{ output_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
+      - "{{ remote_tmp_dir }}/tmpdir/*.txt"
+      - "{{ remote_tmp_dir }}/tmpdir/sub/*"
+    dest: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
     format: "{{ format }}"
     remove: yes
-    exclude_path: "{{ output_dir }}/tmpdir/sub/subfile.txt"
+    exclude_path: "{{ remote_tmp_dir }}/tmpdir/sub/subfile.txt"
   register: archive_remove_source_excluding_sub_path
 
 - name: Verify archive exists - remove source excluding sub path ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
     state: file
 
 - name: Remove archive - remove source excluding sub path ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_excluding_sub_path.{{ format }}"
     state: absent
 
 - name: Verify that sub path still exists - remove source excluding sub path ({{ format }})
   file:
-    path: "{{ output_dir }}/tmpdir/sub/subfile.txt"
+    path: "{{ remote_tmp_dir }}/tmpdir/sub/subfile.txt"
     state: file
 
 - name: Copy source files to temporary directory - remove source with nested paths ({{ format }})
   copy:
     src: "{{ item }}"
-    dest: "{{ output_dir }}/tmpdir/{{ item }}"
+    dest: "{{ remote_tmp_dir }}/tmpdir/{{ item }}"
   with_items:
     - foo.txt
     - bar.txt
@@ -178,20 +178,20 @@
 
 - name: Archive - remove source with nested paths ({{ format }})
   archive:
-    path: "{{ output_dir }}/tmpdir/"
-    dest: "{{ output_dir }}/archive_remove_source_nested_paths.{{ format }}"
+    path: "{{ remote_tmp_dir }}/tmpdir/"
+    dest: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}"
     format: "{{ format }}"
     remove: yes
   register: archive_remove_nested_paths
 
 - name: Verify archive exists - remove source with nested paths ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_nested_paths.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}"
     state: file
 
 - name: Verify source files were removed - remove source with nested paths ({{ format }})
   file:
-    path: "{{ output_dir }}/tmpdir"
+    path: "{{ remote_tmp_dir }}/tmpdir"
     state: absent
   register: archive_remove_nested_paths_status
 
@@ -203,5 +203,5 @@
 
 - name: Remove archive - remove source with nested paths ({{ format }})
   file:
-    path: "{{ output_dir }}/archive_remove_source_nested_paths.{{ format }}"
+    path: "{{ remote_tmp_dir }}/archive_remove_source_nested_paths.{{ format }}"
     state: absent
diff --git a/tests/integration/targets/consul/meta/main.yml b/tests/integration/targets/consul/meta/main.yml
index f4c99a2ad7..f9bb8406a4 100644
--- a/tests/integration/targets/consul/meta/main.yml
+++ b/tests/integration/targets/consul/meta/main.yml
@@ -2,3 +2,4 @@
 dependencies:
   - setup_pkg_mgr
   - setup_openssl
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/consul/tasks/main.yml b/tests/integration/targets/consul/tasks/main.yml
index 4de2d332e5..7f216f81f0 100644
--- a/tests/integration/targets/consul/tasks/main.yml
+++ b/tests/integration/targets/consul/tasks/main.yml
@@ -7,7 +7,7 @@
   vars:
     consul_version: 1.5.0
     consul_uri: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/consul/consul_{{ consul_version }}_{{ ansible_system | lower }}_{{ consul_arch }}.zip
-    consul_cmd: '{{ output_dir }}/consul'
+    consul_cmd: '{{ remote_tmp_dir }}/consul'
   block:
   - name: register pyOpenSSL version
     command: '{{ ansible_python_interpreter }} -c ''import OpenSSL; print(OpenSSL.__version__)'''
@@ -27,19 +27,19 @@
     block:
     - name: Generate privatekey
       community.crypto.openssl_privatekey:
-        path: '{{ output_dir }}/privatekey.pem'
+        path: '{{ remote_tmp_dir }}/privatekey.pem'
     - name: Generate CSR
       community.crypto.openssl_csr:
-        path: '{{ output_dir }}/csr.csr'
-        privatekey_path: '{{ output_dir }}/privatekey.pem'
+        path: '{{ remote_tmp_dir }}/csr.csr'
+        privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
         subject:
           commonName: localhost
     - name: Generate selfsigned certificate
       register: selfsigned_certificate
       community.crypto.openssl_certificate:
-        path: '{{ output_dir }}/cert.pem'
-        csr_path: '{{ output_dir }}/csr.csr'
-        privatekey_path: '{{ output_dir }}/privatekey.pem'
+        path: '{{ remote_tmp_dir }}/cert.pem'
+        csr_path: '{{ remote_tmp_dir }}/csr.csr'
+        privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
         provider: selfsigned
         selfsigned_digest: sha256
   - name: Install unzip
@@ -59,21 +59,21 @@
   - name: Download consul binary
     unarchive:
       src: '{{ consul_uri }}'
-      dest: '{{ output_dir }}'
+      dest: '{{ remote_tmp_dir }}'
       remote_src: true
     register: result
     until: result is success
   - vars:
-      remote_dir: '{{ echo_output_dir.stdout }}'
+      remote_dir: '{{ echo_remote_tmp_dir.stdout }}'
     block:
-    - command: echo {{ output_dir }}
-      register: echo_output_dir
+    - command: echo {{ remote_tmp_dir }}
+      register: echo_remote_tmp_dir
     - name: Create configuration file
       template:
         src: consul_config.hcl.j2
-        dest: '{{ output_dir }}/consul_config.hcl'
+        dest: '{{ remote_tmp_dir }}/consul_config.hcl'
     - name: Start Consul (dev mode enabled)
-      shell: nohup {{ consul_cmd }} agent -dev -config-file {{ output_dir }}/consul_config.hcl </dev/null >/dev/null 2>&1 &
+      shell: nohup {{ consul_cmd }} agent -dev -config-file {{ remote_tmp_dir }}/consul_config.hcl </dev/null >/dev/null 2>&1 &
     - name: Create some data
       command: '{{ consul_cmd }} kv put data/value{{ item }} foo{{ item }}'
       loop:
@@ -83,5 +83,5 @@
     - import_tasks: consul_session.yml
     always:
     - name: Kill consul process
-      shell: kill $(cat {{ output_dir }}/consul.pid)
+      shell: kill $(cat {{ remote_tmp_dir }}/consul.pid)
       ignore_errors: true
diff --git a/tests/integration/targets/deploy_helper/meta/main.yml b/tests/integration/targets/deploy_helper/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/deploy_helper/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/deploy_helper/tasks/main.yml b/tests/integration/targets/deploy_helper/tasks/main.yml
index a61ab2a075..6d03b8da0e 100644
--- a/tests/integration/targets/deploy_helper/tasks/main.yml
+++ b/tests/integration/targets/deploy_helper/tasks/main.yml
@@ -5,7 +5,7 @@
 ####################################################################
 
 - name: record the output directory
-  set_fact: deploy_helper_test_root={{output_dir}}/deploy_helper_test_root
+  set_fact: deploy_helper_test_root={{remote_tmp_dir}}/deploy_helper_test_root
 
 - name: State=query with default parameters
   deploy_helper: path={{ deploy_helper_test_root }} state=query
diff --git a/tests/integration/targets/filter_random_mac/meta/main.yml b/tests/integration/targets/filter_random_mac/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/filter_random_mac/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/filter_random_mac/tasks/main.yml b/tests/integration/targets/filter_random_mac/tasks/main.yml
index 782b6e5c95..e09017c6fb 100644
--- a/tests/integration/targets/filter_random_mac/tasks/main.yml
+++ b/tests/integration/targets/filter_random_mac/tasks/main.yml
@@ -8,9 +8,6 @@
 # Copyright: (c) 2019, Ansible Project
 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
 
-- set_fact:
-    output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
-
 - name: Test random_mac filter bad argument type
   debug:
     var: "0 | community.general.random_mac"
diff --git a/tests/integration/targets/flatpak/tasks/setup.yml b/tests/integration/targets/flatpak/tasks/setup.yml
index 8fc0a23566..decf20d166 100644
--- a/tests/integration/targets/flatpak/tasks/setup.yml
+++ b/tests/integration/targets/flatpak/tasks/setup.yml
@@ -57,7 +57,7 @@
     mode: '0755'
 
 - name: Start HTTP server
-  command: '{{ remote_tmp_dir }}/serve.py 127.0.0.1 8000 /tmp/flatpak/'
+  command: '{{ ansible_python.executable }} {{ remote_tmp_dir }}/serve.py 127.0.0.1 8000 /tmp/flatpak/'
   async: 120
   poll: 0
   register: webserver_status
diff --git a/tests/integration/targets/gem/meta/main.yml b/tests/integration/targets/gem/meta/main.yml
index 5438ced5c3..56bc554611 100644
--- a/tests/integration/targets/gem/meta/main.yml
+++ b/tests/integration/targets/gem/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_pkg_mgr
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/gem/tasks/main.yml b/tests/integration/targets/gem/tasks/main.yml
index 499057775c..4674fb1075 100644
--- a/tests/integration/targets/gem/tasks/main.yml
+++ b/tests/integration/targets/gem/tasks/main.yml
@@ -122,7 +122,7 @@
   gem:
     name: gist
     state: present
-    install_dir: "{{ output_dir }}/gems"
+    install_dir: "{{ remote_tmp_dir }}/gems"
   ignore_errors: yes
   register: install_gem_fail_result
 
@@ -141,12 +141,12 @@
     name: gist
     state: present
     user_install: no
-    install_dir: "{{ output_dir }}/gems"
+    install_dir: "{{ remote_tmp_dir }}/gems"
   register: install_gem_result
 
 - name: Find gems in custom directory
   find:
-    paths: "{{ output_dir }}/gems/gems"
+    paths: "{{ remote_tmp_dir }}/gems/gems"
     file_type: directory
     contains: gist
   register: gem_search
@@ -163,12 +163,12 @@
     name: gist
     state: absent
     user_install: no
-    install_dir: "{{ output_dir }}/gems"
+    install_dir: "{{ remote_tmp_dir }}/gems"
   register: install_gem_result
 
 - name: Find gems in custom directory
   find:
-    paths: "{{ output_dir }}/gems/gems"
+    paths: "{{ remote_tmp_dir }}/gems/gems"
     file_type: directory
     contains: gist
   register: gem_search
@@ -184,14 +184,14 @@
   gem:
     name: gist
     state: present
-    bindir: "{{ output_dir }}/custom_bindir"
+    bindir: "{{ remote_tmp_dir }}/custom_bindir"
     norc: yes
     user_install: no  # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL
   register: install_gem_result
 
 - name: Get stats of gem executable
   stat:
-    path: "{{ output_dir }}/custom_bindir/gist"
+    path: "{{ remote_tmp_dir }}/custom_bindir/gist"
   register: gem_bindir_stat
 
 - name: Ensure gem executable was installed in custom directory
@@ -204,14 +204,14 @@
   gem:
     name: gist
     state: absent
-    bindir: "{{ output_dir }}/custom_bindir"
+    bindir: "{{ remote_tmp_dir }}/custom_bindir"
     norc: yes
     user_install: no  # Avoid conflicts between --install-dir and --user-install when running as root on CentOS / Fedora / RHEL
   register: install_gem_result
 
 - name: Get stats of gem executable
   stat:
-    path: "{{ output_dir }}/custom_bindir/gist"
+    path: "{{ remote_tmp_dir }}/custom_bindir/gist"
   register: gem_bindir_stat
 
 - name: Ensure gem executable was removed from custom directory
diff --git a/tests/integration/targets/git_config/meta/main.yml b/tests/integration/targets/git_config/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/git_config/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/git_config/tasks/get_set_state_present_file.yml b/tests/integration/targets/git_config/tasks/get_set_state_present_file.yml
index 20946ac393..5d46ed35c5 100644
--- a/tests/integration/targets/git_config/tasks/get_set_state_present_file.yml
+++ b/tests/integration/targets/git_config/tasks/get_set_state_present_file.yml
@@ -6,7 +6,7 @@
     name: "{{ option_name }}"
     value: "{{ option_value }}"
     scope: "file"
-    file: "{{ output_dir }}/gitconfig_file"
+    file: "{{ remote_tmp_dir }}/gitconfig_file"
     state: present
   register: result
 
@@ -14,7 +14,7 @@
   git_config:
     name: "{{ option_name }}"
     scope: "file"
-    file: "{{ output_dir }}/gitconfig_file"
+    file: "{{ remote_tmp_dir }}/gitconfig_file"
     state: present
   register: get_result
 
@@ -26,4 +26,3 @@
       - set_result.diff.after == option_value + "\n"
       - get_result is not changed
       - get_result.config_value == option_value
-...
diff --git a/tests/integration/targets/git_config/tasks/setup_no_value.yml b/tests/integration/targets/git_config/tasks/setup_no_value.yml
index d5552450cf..7bccfc0368 100644
--- a/tests/integration/targets/git_config/tasks/setup_no_value.yml
+++ b/tests/integration/targets/git_config/tasks/setup_no_value.yml
@@ -8,6 +8,5 @@
 
 - name: set up without value (file)
   file:
-    path: "{{ output_dir }}/gitconfig_file"
+    path: "{{ remote_tmp_dir }}/gitconfig_file"
     state: absent
-...
diff --git a/tests/integration/targets/git_config/tasks/setup_value.yml b/tests/integration/targets/git_config/tasks/setup_value.yml
index 3eff9c423a..748e838b3d 100644
--- a/tests/integration/targets/git_config/tasks/setup_value.yml
+++ b/tests/integration/targets/git_config/tasks/setup_value.yml
@@ -9,5 +9,4 @@
 - name: set up with value (file)
   copy:
     src: gitconfig
-    dest: "{{ output_dir }}/gitconfig_file"
-...
+    dest: "{{ remote_tmp_dir }}/gitconfig_file"
diff --git a/tests/integration/targets/hg/meta/main.yml b/tests/integration/targets/hg/meta/main.yml
index 5438ced5c3..56bc554611 100644
--- a/tests/integration/targets/hg/meta/main.yml
+++ b/tests/integration/targets/hg/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_pkg_mgr
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/hg/tasks/run-tests.yml b/tests/integration/targets/hg/tasks/run-tests.yml
index 775b297817..0818f4f466 100644
--- a/tests/integration/targets/hg/tasks/run-tests.yml
+++ b/tests/integration/targets/hg/tasks/run-tests.yml
@@ -6,14 +6,14 @@
 
 - name: set where to extract the repo
   set_fact:
-    checkout_dir: "{{ output_dir }}/hg_project_test"
+    checkout_dir: "{{ remote_tmp_dir }}/hg_project_test"
 
 - name: set what repo to use
   set_fact:
     repo: "http://hg.pf.osdn.net/view/a/ak/akasurde/hg_project_test"
 
-- name: clean out the output_dir
-  shell: rm -rf {{ output_dir }}/*
+- name: clean out the remote_tmp_dir
+  shell: rm -rf {{ remote_tmp_dir }}/*
 
 - name: verify that mercurial is installed so this test can continue
   shell: which hg
diff --git a/tests/integration/targets/iso_create/meta/main.yml b/tests/integration/targets/iso_create/meta/main.yml
index 5438ced5c3..56bc554611 100644
--- a/tests/integration/targets/iso_create/meta/main.yml
+++ b/tests/integration/targets/iso_create/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_pkg_mgr
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/iso_create/tasks/main.yml b/tests/integration/targets/iso_create/tasks/main.yml
index 4a0df3b818..0e21e01aef 100644
--- a/tests/integration/targets/iso_create/tasks/main.yml
+++ b/tests/integration/targets/iso_create/tasks/main.yml
@@ -14,15 +14,23 @@
 - debug: var=install_pycdlib
 
 - set_fact:
-    output_dir_test: '{{ output_dir }}/test_iso_create'
+    output_test_dir: '{{ remote_tmp_dir }}/test_iso_create'
 
 # - include_tasks: prepare_dest_dir.yml
 
+- name: Copy files and directories
+  copy:
+    src: '{{ item }}'
+    dest: '{{ remote_tmp_dir }}/{{ item }}'
+  loop:
+    - test1.cfg
+    - test_dir
+
 - name: Test check mode
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-    dest_iso: "{{ output_dir_test }}/test.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+    dest_iso: "{{ output_test_dir }}/test.iso"
     interchange_level: 3
   register: iso_result
   check_mode: yes
@@ -30,7 +38,7 @@
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test.iso"
+    path: "{{ output_test_dir }}/test.iso"
   register: iso_file
 - debug: var=iso_file
 - assert:
@@ -41,15 +49,15 @@
 - name: Create iso file with a specified file
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-    dest_iso: "{{ output_dir_test }}/test.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+    dest_iso: "{{ output_test_dir }}/test.iso"
     interchange_level: 3
   register: iso_result
 - debug: var=iso_result
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test.iso"
+    path: "{{ output_test_dir }}/test.iso"
   register: iso_file
 
 - assert:
@@ -60,16 +68,16 @@
 - name: Create iso file with a specified file and folder
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-      - "{{ role_path }}/files/test_dir"
-    dest_iso: "{{ output_dir_test }}/test1.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+      - "{{ remote_tmp_dir }}/test_dir"
+    dest_iso: "{{ output_test_dir }}/test1.iso"
     interchange_level: 3
   register: iso_result
 - debug: var=iso_result
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test1.iso"
+    path: "{{ output_test_dir }}/test1.iso"
   register: iso_file
 
 - assert:
@@ -80,15 +88,15 @@
 - name: Create iso file with volume identification string
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-    dest_iso: "{{ output_dir_test }}/test2.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+    dest_iso: "{{ output_test_dir }}/test2.iso"
     vol_ident: "OEMDRV"
   register: iso_result
 - debug: var=iso_result
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test2.iso"
+    path: "{{ output_test_dir }}/test2.iso"
   register: iso_file
 
 - assert:
@@ -99,15 +107,15 @@
 - name: Create iso file with Rock Ridge extention
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-    dest_iso: "{{ output_dir_test }}/test3.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+    dest_iso: "{{ output_test_dir }}/test3.iso"
     rock_ridge: "1.09"
   register: iso_result
 - debug: var=iso_result
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test3.iso"
+    path: "{{ output_test_dir }}/test3.iso"
   register: iso_file
 
 - assert:
@@ -118,15 +126,15 @@
 - name: Create iso file with Joliet extention
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-    dest_iso: "{{ output_dir_test }}/test4.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+    dest_iso: "{{ output_test_dir }}/test4.iso"
     joliet: 3
   register: iso_result
 - debug: var=iso_result
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test4.iso"
+    path: "{{ output_test_dir }}/test4.iso"
   register: iso_file
 
 - assert:
@@ -137,15 +145,15 @@
 - name: Create iso file with UDF enabled
   iso_create:
     src_files:
-      - "{{ role_path }}/files/test1.cfg"
-    dest_iso: "{{ output_dir_test }}/test5.iso"
+      - "{{ remote_tmp_dir }}/test1.cfg"
+    dest_iso: "{{ output_test_dir }}/test5.iso"
     udf: True
   register: iso_result
 - debug: var=iso_result
 
 - name: Check if iso file created
   stat:
-    path: "{{ output_dir_test }}/test5.iso"
+    path: "{{ output_test_dir }}/test5.iso"
   register: iso_file
 
 - assert:
diff --git a/tests/integration/targets/iso_create/tasks/prepare_dest_dir.yml b/tests/integration/targets/iso_create/tasks/prepare_dest_dir.yml
index 94c529d52a..8320c3942e 100644
--- a/tests/integration/targets/iso_create/tasks/prepare_dest_dir.yml
+++ b/tests/integration/targets/iso_create/tasks/prepare_dest_dir.yml
@@ -3,10 +3,10 @@
 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
 - name: Make sure our testing sub-directory does not exist
   file:
-    path: '{{ output_dir_test }}'
+    path: '{{ output_test_dir }}'
     state: absent
 
 - name: Create our testing sub-directory
   file:
-    path: '{{ output_dir_test }}'
+    path: '{{ output_test_dir }}'
     state: directory
diff --git a/tests/integration/targets/iso_extract/meta/main.yml b/tests/integration/targets/iso_extract/meta/main.yml
index 0e51c36ebd..07990bd4ef 100644
--- a/tests/integration/targets/iso_extract/meta/main.yml
+++ b/tests/integration/targets/iso_extract/meta/main.yml
@@ -1,3 +1,4 @@
 dependencies:
   - setup_pkg_mgr
   - setup_epel
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/iso_extract/tasks/main.yml b/tests/integration/targets/iso_extract/tasks/main.yml
index 1eb279a3d2..18fd9b37a9 100644
--- a/tests/integration/targets/iso_extract/tasks/main.yml
+++ b/tests/integration/targets/iso_extract/tasks/main.yml
@@ -23,7 +23,7 @@
 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
 
 - set_fact:
-    output_dir_test: '{{ output_dir }}/test_iso_extract'
+    output_test_dir: '{{ remote_tmp_dir }}/test_iso_extract'
 
 - name: Install 7zip
   import_tasks: 7zip.yml
diff --git a/tests/integration/targets/iso_extract/tasks/prepare.yml b/tests/integration/targets/iso_extract/tasks/prepare.yml
index 78c06ad52c..4e240caca6 100644
--- a/tests/integration/targets/iso_extract/tasks/prepare.yml
+++ b/tests/integration/targets/iso_extract/tasks/prepare.yml
@@ -19,15 +19,15 @@
 
 - name: Make sure our testing sub-directory does not exist
   file:
-    path: '{{ output_dir_test }}'
+    path: '{{ output_test_dir }}'
     state: absent
 
 - name: Create our testing sub-directory
   file:
-    path: '{{ output_dir_test }}'
+    path: '{{ output_test_dir }}'
     state: directory
 
 - name: copy the iso to the test dir
   copy:
       src: test.iso
-      dest: '{{ output_dir_test }}'
+      dest: '{{ output_test_dir }}'
diff --git a/tests/integration/targets/iso_extract/tasks/tests.yml b/tests/integration/targets/iso_extract/tasks/tests.yml
index 18f22422ce..1475027adf 100644
--- a/tests/integration/targets/iso_extract/tasks/tests.yml
+++ b/tests/integration/targets/iso_extract/tasks/tests.yml
@@ -19,8 +19,8 @@
 
 - name: Extract the iso
   iso_extract:
-    image: '{{ output_dir_test }}/test.iso'
-    dest: '{{ output_dir_test }}'
+    image: '{{ output_test_dir }}/test.iso'
+    dest: '{{ output_test_dir }}'
     files:
     - 1.txt
     - 2.txt
@@ -32,8 +32,8 @@
 
 - name: Extract the iso again
   iso_extract:
-    image: '{{ output_dir_test }}/test.iso'
-    dest: '{{ output_dir_test }}'
+    image: '{{ output_test_dir }}/test.iso'
+    dest: '{{ output_test_dir }}'
     files:
     - 1.txt
     - 2.txt
diff --git a/tests/integration/targets/java_cert/defaults/main.yml b/tests/integration/targets/java_cert/defaults/main.yml
index 8e63493600..b391eeff2d 100644
--- a/tests/integration/targets/java_cert/defaults/main.yml
+++ b/tests/integration/targets/java_cert/defaults/main.yml
@@ -1,15 +1,15 @@
 ---
 test_pkcs12_path: testpkcs.p12
 test_keystore_path: keystore.jks
-test_keystore2_path: "{{ output_dir }}/keystore2.jks"
+test_keystore2_path: "{{ remote_tmp_dir }}/keystore2.jks"
 test_keystore2_password: changeit
-test_cert_path: "{{ output_dir }}/cert.pem"
-test_key_path: "{{ output_dir }}/key.pem"
-test_csr_path: "{{ output_dir }}/req.csr"
-test_cert2_path: "{{ output_dir }}/cert2.pem"
-test_key2_path: "{{ output_dir }}/key2.pem"
-test_csr2_path: "{{ output_dir }}/req2.csr"
-test_pkcs_path: "{{ output_dir }}/cert.p12"
-test_pkcs2_path: "{{ output_dir }}/cert2.p12"
+test_cert_path: "{{ remote_tmp_dir }}/cert.pem"
+test_key_path: "{{ remote_tmp_dir }}/key.pem"
+test_csr_path: "{{ remote_tmp_dir }}/req.csr"
+test_cert2_path: "{{ remote_tmp_dir }}/cert2.pem"
+test_key2_path: "{{ remote_tmp_dir }}/key2.pem"
+test_csr2_path: "{{ remote_tmp_dir }}/req2.csr"
+test_pkcs_path: "{{ remote_tmp_dir }}/cert.p12"
+test_pkcs2_path: "{{ remote_tmp_dir }}/cert2.p12"
 test_ssl: setupSSLServer.py
 test_ssl_port: 21500
diff --git a/tests/integration/targets/java_cert/meta/main.yml b/tests/integration/targets/java_cert/meta/main.yml
index 9bc23ac67f..1d78393199 100644
--- a/tests/integration/targets/java_cert/meta/main.yml
+++ b/tests/integration/targets/java_cert/meta/main.yml
@@ -1,3 +1,4 @@
 dependencies:
   - setup_java_keytool
   - setup_openssl
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/java_cert/tasks/main.yml b/tests/integration/targets/java_cert/tasks/main.yml
index 20550740da..2088e3bfda 100644
--- a/tests/integration/targets/java_cert/tasks/main.yml
+++ b/tests/integration/targets/java_cert/tasks/main.yml
@@ -9,15 +9,15 @@
     - name: prep pkcs12 file
       ansible.builtin.copy:
         src: "{{ test_pkcs12_path }}"
-        dest: "{{ output_dir }}/{{ test_pkcs12_path }}"
+        dest: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
 
     - name: import pkcs12
       community.general.java_cert:
-        pkcs12_path: "{{ output_dir }}/{{ test_pkcs12_path }}"
+        pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
         pkcs12_password: changeit
         pkcs12_alias: default
         cert_alias: default
-        keystore_path: "{{ output_dir }}/{{ test_keystore_path }}"
+        keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
         keystore_pass: changeme_keystore
         keystore_create: yes
         state: present
@@ -30,11 +30,11 @@
 
     - name: import pkcs12 with wrong password
       community.general.java_cert:
-        pkcs12_path: "{{ output_dir }}/{{ test_pkcs12_path }}"
+        pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
         pkcs12_password: wrong_pass
         pkcs12_alias: default
         cert_alias: default_new
-        keystore_path: "{{ output_dir }}/{{ test_keystore_path }}"
+        keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
         keystore_pass: changeme_keystore
         keystore_create: yes
         state: present
@@ -49,9 +49,9 @@
     - name: test fail on mutually exclusive params
       community.general.java_cert:
         cert_path: ca.crt
-        pkcs12_path: "{{ output_dir }}/{{ test_pkcs12_path }}"
+        pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
         cert_alias: default
-        keystore_path: "{{ output_dir }}/{{ test_keystore_path }}"
+        keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
         keystore_pass: changeme_keystore
         keystore_create: yes
         state: present
@@ -65,7 +65,7 @@
 
     - name: test fail on missing required params
       community.general.java_cert:
-        keystore_path: "{{ output_dir }}/{{ test_keystore_path }}"
+        keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
         keystore_pass: changeme_keystore
         state: absent
       ignore_errors: true
@@ -78,7 +78,7 @@
 
     - name: delete object based on cert_alias parameter
       community.general.java_cert:
-        keystore_path: "{{ output_dir }}/{{ test_keystore_path }}"
+        keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
         keystore_pass: changeme_keystore
         cert_alias: default
         state: absent
@@ -98,8 +98,8 @@
         path: "{{ item }}"
         state: absent
       loop:
-        - "{{ output_dir }}/{{ test_pkcs12_path }}"
-        - "{{ output_dir }}/{{ test_keystore_path }}"
+        - "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
+        - "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
         - "{{ test_keystore2_path }}"
         - "{{ test_cert_path }}"
         - "{{ test_key_path }}"
diff --git a/tests/integration/targets/java_cert/tasks/state_change.yml b/tests/integration/targets/java_cert/tasks/state_change.yml
index 38ef62cd0f..c0b92c8d2a 100644
--- a/tests/integration/targets/java_cert/tasks/state_change.yml
+++ b/tests/integration/targets/java_cert/tasks/state_change.yml
@@ -239,13 +239,17 @@
 - name: Copy the ssl server script
   copy:
     src: "setupSSLServer.py"
-    dest: "{{ output_dir }}"
+    dest: "{{ remote_tmp_dir }}"
 
 - name: Create an SSL server that we will use for testing URL imports
-  command: python {{ output_dir }}/setupSSLServer.py {{ output_dir }} {{ test_ssl_port }}
+  command: "{{ ansible_python.executable }} {{ remote_tmp_dir }}/setupSSLServer.py {{ remote_tmp_dir }} {{ test_ssl_port }}"
   async: 10
   poll: 0
 
+- name: "Wait for one second to make sure that the serve script has actually been started"
+  pause:
+    seconds: 1
+
 - name: |
     Download the original cert.pem from our temporary server. The current cert should contain
      cert2.pem. Importing this cert should return a status of changed
diff --git a/tests/integration/targets/java_keystore/meta/main.yml b/tests/integration/targets/java_keystore/meta/main.yml
index 9bc23ac67f..1d78393199 100644
--- a/tests/integration/targets/java_keystore/meta/main.yml
+++ b/tests/integration/targets/java_keystore/meta/main.yml
@@ -1,3 +1,4 @@
 dependencies:
   - setup_java_keytool
   - setup_openssl
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/java_keystore/tasks/prepare.yml b/tests/integration/targets/java_keystore/tasks/prepare.yml
index f8811c03ed..04b7cbd9d8 100644
--- a/tests/integration/targets/java_keystore/tasks/prepare.yml
+++ b/tests/integration/targets/java_keystore/tasks/prepare.yml
@@ -1,12 +1,12 @@
 ---
 - name: Create test directory
   ansible.builtin.file:
-    path: "{{ output_dir }}"
+    path: "{{ remote_tmp_dir }}"
     state: directory
 
 - name: Create private keys
   community.crypto.openssl_privatekey:
-    path: "{{ output_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}"
     size: 2048  # this should work everywhere
     # The following is more efficient, but might not work everywhere:
     # type: ECC
@@ -17,17 +17,17 @@
 
 - name: Create CSRs
   community.crypto.openssl_csr:
-    path: "{{ output_dir ~ '/' ~ item.name ~ '.csr' }}"
-    privatekey_path: "{{ output_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.csr' }}"
+    privatekey_path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}"
     privatekey_passphrase: "{{ item.passphrase | default(omit) }}"
     commonName: "{{ item.commonName }}"
   loop: "{{ java_keystore_certs + java_keystore_new_certs }}"
 
 - name: Create certificates
   community.crypto.x509_certificate:
-    path: "{{ output_dir ~ '/' ~ item.name ~ '.pem' }}"
-    csr_path: "{{ output_dir ~ '/' ~ item.name ~ '.csr' }}"
-    privatekey_path: "{{ output_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}"
+    csr_path: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.csr' }}"
+    privatekey_path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}"
     privatekey_passphrase: "{{ item.passphrase | default(omit) }}"
     provider: selfsigned
   loop: "{{ java_keystore_certs + java_keystore_new_certs }}"
diff --git a/tests/integration/targets/java_keystore/tasks/tests.yml b/tests/integration/targets/java_keystore/tasks/tests.yml
index 8510a64165..07b30ad97d 100644
--- a/tests/integration/targets/java_keystore/tasks/tests.yml
+++ b/tests/integration/targets/java_keystore/tasks/tests.yml
@@ -1,199 +1,273 @@
 ---
 - name: Create test directory
   ansible.builtin.file:
-    path: "{{ output_dir }}"
+    path: "{{ remote_tmp_dir }}"
     state: directory
 
 - name: Ensure the Java keystore does not exist (cleanup between tests)
   ansible.builtin.file:
-    path: "{{ output_dir ~ '/' ~ item.name ~ '.jks' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.jks' }}"
     state: absent
   loop: "{{ java_keystore_certs }}"
   loop_control:
-    label: "{{ output_dir ~ '/' ~ item.name ~ '.jks' }}"
+    label: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.jks' }}"
 
 
+- name: Read certificates
+  slurp:
+    src: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}"
+  loop: "{{ java_keystore_certs }}"
+  when: not remote_cert
+  register: certificates
+
+- name: Read certificate keys
+  slurp:
+    src: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}"
+  loop: "{{ java_keystore_certs }}"
+  when: not remote_cert
+  register: certificate_keys
+
 - name: Create a Java keystore for the given ({{ 'remote' if remote_cert else 'local' }}) certificates (check mode)
   community.general.java_keystore: &java_keystore_params
     name: example
-    dest: "{{ output_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
-    certificate: "{{ omit if remote_cert else lookup('file', output_dir ~ '/' ~ item.name ~ '.pem') }}"
-    private_key: "{{ omit if remote_cert else lookup('file', output_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key') }}"
-    certificate_path: "{{ omit if not remote_cert else output_dir ~ '/' ~ item.name ~ '.pem' }}"
-    private_key_path: "{{ omit if not remote_cert else output_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}"
+    dest: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
+    certificate: "{{ omit if remote_cert else (certificates.results[loop_index].content | b64decode) }}"
+    private_key: "{{ omit if remote_cert else (certificate_keys.results[loop_index].content | b64decode) }}"
+    certificate_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}"
+    private_key_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}"
     private_key_passphrase: "{{ item.passphrase | d(omit) }}"
     password: changeit
     ssl_backend: "{{ ssl_backend }}"
     keystore_type: "{{ item.keystore_type | d(omit) }}"
   loop: "{{ java_keystore_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_check
 
 - name: Create a Java keystore for the given certificates
   community.general.java_keystore: *java_keystore_params
   loop: "{{ java_keystore_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result
 
 
 - name: Create a Java keystore for the given certificates (idempotency, check mode)
   community.general.java_keystore: *java_keystore_params
   loop: "{{ java_keystore_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_idem_check
 
 - name: Create a Java keystore for the given certificates (idempotency)
   community.general.java_keystore: *java_keystore_params
   loop: "{{ java_keystore_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_idem
 
 
-- name: Create a Java keystore for the given certificates (certificate changed, check mode)
-  community.general.java_keystore: *java_keystore_params
+- name: Read certificates (new)
+  slurp:
+    src: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}"
   loop: "{{ java_keystore_new_certs }}"
+  when: not remote_cert
+  register: certificates_new
+
+- name: Read certificate keys (new)
+  slurp:
+    src: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}"
+  loop: "{{ java_keystore_new_certs }}"
+  when: not remote_cert
+  register: certificate_keys_new
+
+- name: Create a Java keystore for the given certificates (certificate changed, check mode)
+  community.general.java_keystore: &java_keystore_params_new_certs
+    name: example
+    dest: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
+    certificate: "{{ omit if remote_cert else (certificates_new.results[loop_index].content | b64decode) }}"
+    private_key: "{{ omit if remote_cert else (certificate_keys_new.results[loop_index].content | b64decode) }}"
+    certificate_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}"
+    private_key_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}"
+    private_key_passphrase: "{{ item.passphrase | d(omit) }}"
+    password: changeit
+    ssl_backend: "{{ ssl_backend }}"
+    keystore_type: "{{ item.keystore_type | d(omit) }}"
+  loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_change_check
 
 - name: Create a Java keystore for the given certificates (certificate changed)
-  community.general.java_keystore: *java_keystore_params
+  community.general.java_keystore: *java_keystore_params_new_certs
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_change
 
 
 - name: Create a Java keystore for the given certificates (alias changed, check mode)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_alias_change_check
 
 - name: Create a Java keystore for the given certificates (alias changed)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_alias_change
 
 
 - name: Create a Java keystore for the given certificates (password changed, check mode)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_pw_change_check
 
 - name: Create a Java keystore for the given certificates (password changed)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_pw_change
 
 
 - name: Create a Java keystore for the given certificates (force keystore type pkcs12, check mode)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
     keystore_type: pkcs12
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_type_pkcs12_check
 
 - name: Create a Java keystore for the given certificates (force keystore type jks, check mode)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
     keystore_type: jks
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_type_jks_check
 
 - name: Create a Java keystore for the given certificates (force keystore type jks)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
     keystore_type: jks
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_type_jks
 
 
 - name: Stat keystore (before failure)
   ansible.builtin.stat:
-    path: "{{ output_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
   loop: "{{ java_keystore_new_certs }}"
   register: result_stat_before
 
 - name: Fail to create a Java keystore for the given certificates (password too short)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: short
     keystore_type: jks
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_fail_jks
   ignore_errors: true
 
 - name: Stat keystore (after failure)
   ansible.builtin.stat:
-    path: "{{ output_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}"
   loop: "{{ java_keystore_new_certs }}"
   register: result_stat_after
 
 
 - name: Create a Java keystore for the given certificates (keystore type changed, check mode)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
     keystore_type: pkcs12
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_type_change_check
 
 - name: Create a Java keystore for the given certificates (keystore type changed)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
     keystore_type: pkcs12
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_type_change
 
 
 - name: Create a Java keystore for the given certificates (omit keystore type, check mode)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   check_mode: yes
   register: result_type_omit_check
 
 - name: Create a Java keystore for the given certificates (omit keystore type)
   community.general.java_keystore:
-    <<: *java_keystore_params
+    <<: *java_keystore_params_new_certs
     name: foobar
     password: hunter2
   loop: "{{ java_keystore_new_certs }}"
+  loop_control:
+    index_var: loop_index
   register: result_type_omit
 
 
 - name: Check that the remote certificates have not been removed
   ansible.builtin.file:
-    path: "{{ output_dir ~ '/' ~ item.name ~ '.pem' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}"
     state: file
   loop: "{{ java_keystore_certs + java_keystore_new_certs }}"
   when: remote_cert
 
 - name: Check that the remote private keys have not been removed
   ansible.builtin.file:
-    path: "{{ output_dir ~ '/' ~ item.name ~ '.key' }}"
+    path: "{{ remote_tmp_dir ~ '/' ~ item.name ~ '.key' }}"
     state: file
   loop: "{{ java_keystore_certs }}"
   when: remote_cert
diff --git a/tests/integration/targets/mail/meta/main.yml b/tests/integration/targets/mail/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/mail/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/mail/tasks/main.yml b/tests/integration/targets/mail/tasks/main.yml
index 714b662dfd..dbde6743d2 100644
--- a/tests/integration/targets/mail/tasks/main.yml
+++ b/tests/integration/targets/mail/tasks/main.yml
@@ -16,7 +16,7 @@
 - name: Install test smtpserver
   copy:
     src: '{{ item }}'
-    dest: '{{ output_dir }}/{{ item }}'
+    dest: '{{ remote_tmp_dir }}/{{ item }}'
   loop:
   - smtpserver.py
   - smtpserver.crt
@@ -25,7 +25,7 @@
 # FIXME: Verify the mail after it was send would be nice
 #        This would require either dumping the content, or registering async task output
 - name: Start test smtpserver
-  shell: '{{ ansible_python.executable }} {{ output_dir }}/smtpserver.py 10025:10465'
+  shell: '{{ ansible_python.executable }} {{ remote_tmp_dir }}/smtpserver.py 10025:10465'
   async: 30
   poll: 0
   register: smtpserver
diff --git a/tests/integration/targets/nomad/meta/main.yml b/tests/integration/targets/nomad/meta/main.yml
index f4c99a2ad7..f9bb8406a4 100644
--- a/tests/integration/targets/nomad/meta/main.yml
+++ b/tests/integration/targets/nomad/meta/main.yml
@@ -2,3 +2,4 @@
 dependencies:
   - setup_pkg_mgr
   - setup_openssl
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/nomad/tasks/main.yml b/tests/integration/targets/nomad/tasks/main.yml
index 1e42e7b2f6..81833684f0 100644
--- a/tests/integration/targets/nomad/tasks/main.yml
+++ b/tests/integration/targets/nomad/tasks/main.yml
@@ -6,7 +6,7 @@
   vars:
     nomad_version: 0.12.4
     nomad_uri: https://releases.hashicorp.com/nomad/{{ nomad_version }}/nomad_{{ nomad_version }}_{{ ansible_system | lower }}_{{ nomad_arch }}.zip
-    nomad_cmd: '{{ output_dir }}/nomad'
+    nomad_cmd: '{{ remote_tmp_dir }}/nomad'
   block:
 
   - name: register pyOpenSSL version
@@ -36,21 +36,21 @@
     block:
     - name: Generate privatekey
       community.crypto.openssl_privatekey:
-        path: '{{ output_dir }}/privatekey.pem'
+        path: '{{ remote_tmp_dir }}/privatekey.pem'
 
     - name: Generate CSR
       community.crypto.openssl_csr:
-        path: '{{ output_dir }}/csr.csr'
-        privatekey_path: '{{ output_dir }}/privatekey.pem'
+        path: '{{ remote_tmp_dir }}/csr.csr'
+        privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
         subject:
           commonName: localhost
 
     - name: Generate selfsigned certificate
       register: selfsigned_certificate
       community.crypto.openssl_certificate:
-        path: '{{ output_dir }}/cert.pem'
-        csr_path: '{{ output_dir }}/csr.csr'
-        privatekey_path: '{{ output_dir }}/privatekey.pem'
+        path: '{{ remote_tmp_dir }}/cert.pem'
+        csr_path: '{{ remote_tmp_dir }}/csr.csr'
+        privatekey_path: '{{ remote_tmp_dir }}/privatekey.pem'
         provider: selfsigned
         selfsigned_digest: sha256
 
@@ -75,17 +75,17 @@
   - name: Download nomad binary
     unarchive:
       src: '{{ nomad_uri }}'
-      dest: '{{ output_dir }}'
+      dest: '{{ remote_tmp_dir }}'
       remote_src: true
     register: result
     until: result is success
 
   - vars:
-      remote_dir: '{{ echo_output_dir.stdout }}'
+      remote_dir: '{{ echo_remote_tmp_dir.stdout }}'
     block:
 
-    - command: echo {{ output_dir }}
-      register: echo_output_dir
+    - command: echo {{ remote_tmp_dir }}
+      register: echo_remote_tmp_dir
 
     - name: Run tests integration
       block:
diff --git a/tests/integration/targets/npm/meta/main.yml b/tests/integration/targets/npm/meta/main.yml
index 392c359035..230548b160 100644
--- a/tests/integration/targets/npm/meta/main.yml
+++ b/tests/integration/targets/npm/meta/main.yml
@@ -1,3 +1,4 @@
 dependencies:
   - setup_pkg_mgr
   - setup_gnutar
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/npm/tasks/main.yml b/tests/integration/targets/npm/tasks/main.yml
index ed5a16a624..c3971fd91d 100644
--- a/tests/integration/targets/npm/tasks/main.yml
+++ b/tests/integration/targets/npm/tasks/main.yml
@@ -25,7 +25,7 @@
 # Setup steps
 
 # expand remote path
-- command: 'echo {{ output_dir }}'
+- command: 'echo {{ remote_tmp_dir }}'
   register: echo
 - set_fact:
     remote_dir: '{{ echo.stdout }}'
diff --git a/tests/integration/targets/npm/tasks/setup.yml b/tests/integration/targets/npm/tasks/setup.yml
index 4e0d908e33..a463b1f8b7 100644
--- a/tests/integration/targets/npm/tasks/setup.yml
+++ b/tests/integration/targets/npm/tasks/setup.yml
@@ -1,6 +1,6 @@
 - name: 'Download NPM'
   unarchive:
     src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/npm/{{ nodejs_path }}.tar.gz'
-    dest: '{{ output_dir }}'
+    dest: '{{ remote_tmp_dir }}'
     remote_src: yes
-    creates: '{{ output_dir }}/{{ nodejs_path }}.tar.gz'
+    creates: '{{ remote_tmp_dir }}/{{ nodejs_path }}.tar.gz'
diff --git a/tests/integration/targets/pids/meta/main.yml b/tests/integration/targets/pids/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/pids/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/pids/tasks/main.yml b/tests/integration/targets/pids/tasks/main.yml
index b56093cf0c..823d588561 100644
--- a/tests/integration/targets/pids/tasks/main.yml
+++ b/tests/integration/targets/pids/tasks/main.yml
@@ -31,13 +31,21 @@
   register: find_sleep
 
 - name: "Copying 'sleep' binary"
+  command: cp {{ find_sleep.stdout }} {{ remote_tmp_dir }}/{{ random_name }}
+  # The following does not work on macOS 11.1 (it uses shutil.copystat, and that will die with a PermissionError):
+  # copy:
+  #   src: "{{ find_sleep.stdout }}"
+  #   dest: "{{ remote_tmp_dir }}/{{ random_name }}"
+  #   mode: "0777"
+  #   remote_src: true
+
+- name: Copy helper script
   copy:
-    src: "{{ find_sleep.stdout }}"
-    dest: "{{ output_dir }}/{{ random_name }}"
-    mode: "0777"
+    src: obtainpid.sh
+    dest: "{{ remote_tmp_dir }}/obtainpid.sh"
 
 - name: "Running the copy of 'sleep' binary"
-  command: "sh {{ role_path }}/files/obtainpid.sh '{{ output_dir }}/{{ random_name }}' '{{ output_dir }}/obtainpid.txt'"
+  command: "sh {{ remote_tmp_dir }}/obtainpid.sh '{{ remote_tmp_dir }}/{{ random_name }}' '{{ remote_tmp_dir }}/obtainpid.txt'"
 
   async: 100
   poll: 0
@@ -74,7 +82,7 @@
 
 - name: "Reading pid from the file"
   slurp:
-    src:  "{{ output_dir }}/obtainpid.txt"
+    src:  "{{ remote_tmp_dir }}/obtainpid.txt"
   register: newpid
 
 - name: "Verify that the Process IDs (PIDs) returned is not empty and also equal to the PIDs obtained in console"
diff --git a/tests/integration/targets/setup_openssl/tasks/main.yml b/tests/integration/targets/setup_openssl/tasks/main.yml
index 62df7dd5f6..27d485a83f 100644
--- a/tests/integration/targets/setup_openssl/tasks/main.yml
+++ b/tests/integration/targets/setup_openssl/tasks/main.yml
@@ -33,6 +33,27 @@
     extra_args: "-c {{ remote_constraints }}"
   when: ansible_os_family == 'Darwin'
 
+- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in  ['CentOS6', 'RedHat6']
+  block:
+  - name: Install cryptography (Python 3)
+    become: true
+    package:
+      name: '{{ cryptography_package_name_python3 }}'
+    when: not ansible_os_family == 'Darwin' and ansible_python_version is version('3.0', '>=')
+
+  - name: Install cryptography (Python 2)
+    become: true
+    package:
+      name: '{{ cryptography_package_name }}'
+    when: not ansible_os_family == 'Darwin' and ansible_python_version is version('3.0', '<')
+
+  - name: Install cryptography (Darwin)
+    become: true
+    pip:
+      name: cryptography>=3.3
+      extra_args: "-c {{ remote_constraints }}"
+    when: ansible_os_family == 'Darwin'
+
 - name: register pyOpenSSL version
   command: "{{ ansible_python.executable }} -c 'import OpenSSL; print(OpenSSL.__version__)'"
   register: pyopenssl_version
diff --git a/tests/integration/targets/setup_openssl/vars/Debian.yml b/tests/integration/targets/setup_openssl/vars/Debian.yml
index 755c7a083c..7254d00a5f 100644
--- a/tests/integration/targets/setup_openssl/vars/Debian.yml
+++ b/tests/integration/targets/setup_openssl/vars/Debian.yml
@@ -1,3 +1,5 @@
+cryptography_package_name: python-cryptography
+cryptography_package_name_python3: python3-cryptography
 pyopenssl_package_name: python-openssl
 pyopenssl_package_name_python3: python3-openssl
 openssl_package_name: openssl
diff --git a/tests/integration/targets/setup_openssl/vars/FreeBSD.yml b/tests/integration/targets/setup_openssl/vars/FreeBSD.yml
index 4fef270602..c34b3646f4 100644
--- a/tests/integration/targets/setup_openssl/vars/FreeBSD.yml
+++ b/tests/integration/targets/setup_openssl/vars/FreeBSD.yml
@@ -1,3 +1,5 @@
+cryptography_package_name: py27-cryptography
+cryptography_package_name_python3: "py{{ ansible_python.version.major }}{{ ansible_python.version.minor }}-cryptography"
 pyopenssl_package_name: py27-openssl
 pyopenssl_package_name_python3: "py{{ ansible_python.version.major }}{{ ansible_python.version.minor }}-openssl"
 openssl_package_name: openssl
diff --git a/tests/integration/targets/setup_openssl/vars/RedHat.yml b/tests/integration/targets/setup_openssl/vars/RedHat.yml
index 2959932cd7..5e077d732f 100644
--- a/tests/integration/targets/setup_openssl/vars/RedHat.yml
+++ b/tests/integration/targets/setup_openssl/vars/RedHat.yml
@@ -1,3 +1,5 @@
+cryptography_package_name: python-cryptography
+cryptography_package_name_python3: python3-cryptography
 pyopenssl_package_name: pyOpenSSL
 pyopenssl_package_name_python3: python3-pyOpenSSL
 openssl_package_name: openssl
diff --git a/tests/integration/targets/setup_openssl/vars/Suse.yml b/tests/integration/targets/setup_openssl/vars/Suse.yml
index 2d5200f341..ec2c556bee 100644
--- a/tests/integration/targets/setup_openssl/vars/Suse.yml
+++ b/tests/integration/targets/setup_openssl/vars/Suse.yml
@@ -1,3 +1,5 @@
+cryptography_package_name: python-cryptography
+cryptography_package_name_python3: python3-cryptography
 pyopenssl_package_name: python-pyOpenSSL
 pyopenssl_package_name_python3: python3-pyOpenSSL
 openssl_package_name: openssl
diff --git a/tests/integration/targets/ssh_config/meta/main.yml b/tests/integration/targets/ssh_config/meta/main.yml
index 91a63627f6..4c6838dbe1 100644
--- a/tests/integration/targets/ssh_config/meta/main.yml
+++ b/tests/integration/targets/ssh_config/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_remote_constraints
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/ssh_config/tasks/main.yml b/tests/integration/targets/ssh_config/tasks/main.yml
index bd5acc9e04..74a6f02fd2 100644
--- a/tests/integration/targets/ssh_config/tasks/main.yml
+++ b/tests/integration/targets/ssh_config/tasks/main.yml
@@ -9,15 +9,15 @@
     extra_args: "-c {{ remote_constraints }}"
 
 - set_fact:
-    output_dir_test: '{{ output_dir }}/test_ssh_config'
+    output_test_dir: '{{ remote_tmp_dir }}/test_ssh_config'
 
 - set_fact:
-    ssh_config_test: '{{ output_dir_test }}/ssh_config_test'
-    ssh_private_key: '{{ output_dir_test }}/fake_id_rsa'
+    ssh_config_test: '{{ output_test_dir }}/ssh_config_test'
+    ssh_private_key: '{{ output_test_dir }}/fake_id_rsa'
 
 - name: create a temporary directory
   file:
-    path: "{{ output_dir_test }}"
+    path: "{{ output_test_dir }}"
     state: directory
 
 - name: Copy sample config file
diff --git a/tests/integration/targets/supervisorctl/meta/main.yml b/tests/integration/targets/supervisorctl/meta/main.yml
index 5438ced5c3..56bc554611 100644
--- a/tests/integration/targets/supervisorctl/meta/main.yml
+++ b/tests/integration/targets/supervisorctl/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_pkg_mgr
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/supervisorctl/tasks/main.yml b/tests/integration/targets/supervisorctl/tasks/main.yml
index 2a7ecdcfc0..0c3dd31b76 100644
--- a/tests/integration/targets/supervisorctl/tasks/main.yml
+++ b/tests/integration/targets/supervisorctl/tasks/main.yml
@@ -9,7 +9,7 @@
       suffix: supervisorctl-tests
     register: supervisord_sock_path
 
-  - command: 'echo {{ output_dir }}'
+  - command: 'echo {{ remote_tmp_dir }}'
     register: echo
   - set_fact:
       remote_dir: '{{ echo.stdout }}'
diff --git a/tests/integration/targets/synchronize-buildah/aliases b/tests/integration/targets/synchronize-buildah/aliases
deleted file mode 100644
index 30b10b7ccb..0000000000
--- a/tests/integration/targets/synchronize-buildah/aliases
+++ /dev/null
@@ -1,3 +0,0 @@
-non_local
-needs/root
-unsupported
diff --git a/tests/integration/targets/synchronize-buildah/inventory b/tests/integration/targets/synchronize-buildah/inventory
deleted file mode 100644
index 2eeaf31350..0000000000
--- a/tests/integration/targets/synchronize-buildah/inventory
+++ /dev/null
@@ -1 +0,0 @@
-buildah-container    ansible_host=buildah-container ansible_connection=buildah
diff --git a/tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/files/normal_file.txt b/tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/files/normal_file.txt
deleted file mode 100644
index 33257a92c0..0000000000
--- a/tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/files/normal_file.txt
+++ /dev/null
@@ -1 +0,0 @@
-abnormal content
diff --git a/tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/tasks/main.yml b/tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/tasks/main.yml
deleted file mode 100644
index a80e218921..0000000000
--- a/tests/integration/targets/synchronize-buildah/roles/test_buildah_synchronize/tasks/main.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-####################################################################
-# WARNING: These are designed specifically for Ansible tests       #
-# and should not be used as examples of how to write Ansible roles #
-####################################################################
-
-# test code for the synchronize module
-# (c) 2014, James Tanner <tanner.jc@gmail.com>
-
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
-
-- name: cleanup old files
-  file:
-    path: '{{ output_dir }}'
-    state: absent
-
-- name: ensure the target directory exists
-  file:
-    path: '{{ output_dir }}'
-    state: directory
-
-- name: synchronize file to new filename
-  synchronize:
-    src: normal_file.txt
-    dest: '{{ output_dir }}/remote_file.txt'
-  register: sync_result
-
-- assert:
-    that:
-        - "'changed' in sync_result"
-        - sync_result is changed
-        - "'cmd' in sync_result"
-        - "'rsync' in sync_result.cmd"
-        - "'msg' in sync_result"
-        - "sync_result.msg.startswith('<f+')"
-        - "sync_result.msg.endswith('+ normal_file.txt\n')"
-
-- name: test that the file was really copied over
-  stat:
-    path: "{{ output_dir }}/remote_file.txt"
-  register: stat_result
-
-- assert:
-    that:
-      - "stat_result.stat.exists == True"
-      - "stat_result.stat.checksum == '4f11fb5cd9fe0171ea6fab02ae33f65138f3e44e'"
-
-- name: test that the file is not copied a second time
-  synchronize: src=normal_file.txt dest={{output_dir}}/remote_file.txt
-  register: sync_result
-
-- assert:
-    that:
-     - sync_result is not changed
-
-- name: cleanup old files
-  file:
-    path: '{{ output_dir }}'
-    state: absent
diff --git a/tests/integration/targets/synchronize-buildah/runme.sh b/tests/integration/targets/synchronize-buildah/runme.sh
deleted file mode 100644
index e9e4811f77..0000000000
--- a/tests/integration/targets/synchronize-buildah/runme.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-
-set -ux
-
-CONTAINER_NAME=buildah-container
-
-buildah rm $CONTAINER_NAME >/dev/null 2>/dev/null
-
-set -e
-
-buildah from --name $CONTAINER_NAME docker.io/library/centos:7
-trap '{ buildah rm $CONTAINER_NAME; }' EXIT
-buildah run $CONTAINER_NAME -- yum install -y rsync
-
-ansible-playbook test_synchronize_buildah.yml -c buildah -i inventory -vv
diff --git a/tests/integration/targets/synchronize-buildah/test_synchronize_buildah.yml b/tests/integration/targets/synchronize-buildah/test_synchronize_buildah.yml
deleted file mode 100644
index e1cc96657e..0000000000
--- a/tests/integration/targets/synchronize-buildah/test_synchronize_buildah.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-- hosts: buildah-container
-  connection: buildah
-  gather_facts: no
-  vars:
-    output_dir: /tmp/ansible_test_synchronize_buildah
-  roles:
-  - test_buildah_synchronize
diff --git a/tests/integration/targets/xattr/defaults/main.yml b/tests/integration/targets/xattr/defaults/main.yml
index af18fb8474..c208bf6fb9 100644
--- a/tests/integration/targets/xattr/defaults/main.yml
+++ b/tests/integration/targets/xattr/defaults/main.yml
@@ -1 +1 @@
-test_file: "{{ output_dir }}/foo.txt"
+test_file: "{{ remote_tmp_dir }}/foo.txt"
diff --git a/tests/integration/targets/xattr/meta/main.yml b/tests/integration/targets/xattr/meta/main.yml
index 5438ced5c3..56bc554611 100644
--- a/tests/integration/targets/xattr/meta/main.yml
+++ b/tests/integration/targets/xattr/meta/main.yml
@@ -1,2 +1,3 @@
 dependencies:
   - setup_pkg_mgr
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/yarn/meta/main.yml b/tests/integration/targets/yarn/meta/main.yml
index 392c359035..230548b160 100644
--- a/tests/integration/targets/yarn/meta/main.yml
+++ b/tests/integration/targets/yarn/meta/main.yml
@@ -1,3 +1,4 @@
 dependencies:
   - setup_pkg_mgr
   - setup_gnutar
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/yarn/tasks/run.yml b/tests/integration/targets/yarn/tasks/run.yml
index bd17d7ffeb..906880797f 100644
--- a/tests/integration/targets/yarn/tasks/run.yml
+++ b/tests/integration/targets/yarn/tasks/run.yml
@@ -6,31 +6,31 @@
 - name: 'Download Nodejs'
   unarchive:
     src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yarn/{{ nodejs_path }}.tar.gz'
-    dest: '{{ output_dir }}'
+    dest: '{{ remote_tmp_dir }}'
     remote_src: yes
-    creates: '{{ output_dir }}/{{ nodejs_path }}.tar.gz'
+    creates: '{{ remote_tmp_dir }}/{{ nodejs_path }}.tar.gz'
 
 - name: 'Download Yarn'
   unarchive:
     src: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/yarn/yarn-v{{yarn_version}}.tar.gz'
-    dest: '{{ output_dir }}'
+    dest: '{{ remote_tmp_dir }}'
     remote_src: yes
-    creates: '{{ output_dir }}/yarn-v{{yarn_version}}_pkg.tar.gz'
+    creates: '{{ remote_tmp_dir }}/yarn-v{{yarn_version}}_pkg.tar.gz'
 
 - name: 'Copy node to directory created earlier'
-  command: "mv {{ output_dir }}/{{ nodejs_path }} /usr/local/lib/nodejs/{{nodejs_path}}"
+  command: "mv {{ remote_tmp_dir }}/{{ nodejs_path }} /usr/local/lib/nodejs/{{nodejs_path}}"
 
 # Clean up before running tests
 - name: Remove any previous Nodejs modules
   file:
-    path: '{{output_dir}}/node_modules'
+    path: '{{remote_tmp_dir}}/node_modules'
     state: absent
 
 # Set vars for our test harness
 - vars:
     #node_bin_path: "/usr/local/lib/nodejs/node-v{{nodejs_version}}/bin"
     node_bin_path: "/usr/local/lib/nodejs/{{ nodejs_path }}/bin"
-    yarn_bin_path: "{{ output_dir }}/yarn-v{{ yarn_version }}/bin"
+    yarn_bin_path: "{{ remote_tmp_dir }}/yarn-v{{ yarn_version }}/bin"
     package: 'iconv-lite'
   environment:
     PATH: "{{ node_bin_path }}:{{ansible_env.PATH}}"
@@ -45,11 +45,11 @@
     - name: 'Create dummy package.json'
       copy:
         src: templates/package.j2
-        dest: '{{ output_dir }}/package.json'
+        dest: '{{ remote_tmp_dir }}/package.json'
 
     - name: 'Install all packages.'
       yarn:
-        path: '{{ output_dir }}'
+        path: '{{ remote_tmp_dir }}'
         executable: '{{ yarn_bin_path }}/yarn'
         state: present
       environment:
@@ -57,7 +57,7 @@
 
     - name: 'Install the same package from package.json again.'
       yarn:
-        path: '{{ output_dir }}'
+        path: '{{ remote_tmp_dir }}'
         executable: '{{ yarn_bin_path }}/yarn'
         name: '{{ package }}'
         state: present
@@ -71,7 +71,7 @@
 
     - name: 'Install all packages in check mode.'
       yarn:
-        path: '{{ output_dir }}'
+        path: '{{ remote_tmp_dir }}'
         executable: '{{ yarn_bin_path }}/yarn'
         state: present
       environment:
@@ -89,7 +89,7 @@
 
     - name: 'Install package with explicit version (older version of package)'
       yarn:
-        path: '{{ output_dir }}'
+        path: '{{ remote_tmp_dir }}'
         executable: '{{ yarn_bin_path }}/yarn'
         name: left-pad
         version: 1.1.0
@@ -104,7 +104,7 @@
 
     - name: 'Upgrade old package'
       yarn:
-        path: '{{ output_dir }}'
+        path: '{{ remote_tmp_dir }}'
         executable: '{{ yarn_bin_path }}/yarn'
         name: left-pad
         state: latest
@@ -118,7 +118,7 @@
 
     - name: 'Remove a package'
       yarn:
-        path: '{{ output_dir }}'
+        path: '{{ remote_tmp_dir }}'
         executable: '{{ yarn_bin_path }}/yarn'
         name: '{{ package }}'
         state: absent
diff --git a/tests/integration/targets/zypper/meta/main.yml b/tests/integration/targets/zypper/meta/main.yml
new file mode 100644
index 0000000000..1810d4bec9
--- /dev/null
+++ b/tests/integration/targets/zypper/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+  - setup_remote_tmp_dir
diff --git a/tests/integration/targets/zypper/tasks/zypper.yml b/tests/integration/targets/zypper/tasks/zypper.yml
index eed27ca3b2..30c4f991bc 100644
--- a/tests/integration/targets/zypper/tasks/zypper.yml
+++ b/tests/integration/targets/zypper/tasks/zypper.yml
@@ -150,17 +150,17 @@
 # INSTALL broken local package
 - name: create directory
   file:
-    path: "{{output_dir | expanduser}}/zypper1"
+    path: "{{remote_tmp_dir | expanduser}}/zypper1"
     state: directory
 
 - name: fake rpm package
   file:
-    path: "{{output_dir | expanduser}}/zypper1/broken.rpm"
+    path: "{{remote_tmp_dir | expanduser}}/zypper1/broken.rpm"
     state: touch
 
 - name: install broken rpm
   zypper:
-    name: "{{output_dir | expanduser}}/zypper1/broken.rpm"
+    name: "{{remote_tmp_dir | expanduser}}/zypper1/broken.rpm"
     state: present
   register: zypper_result
   ignore_errors: yes
@@ -191,29 +191,29 @@
 
 - name: create directory
   file:
-    path: "{{output_dir | expanduser}}/zypper2"
+    path: "{{remote_tmp_dir | expanduser}}/zypper2"
     state: directory
 
 - name: copy spec file
   copy:
     src: empty.spec
-    dest: "{{ output_dir | expanduser }}/zypper2/empty.spec"
+    dest: "{{ remote_tmp_dir | expanduser }}/zypper2/empty.spec"
 
 - name: build rpm
   command: |
     rpmbuild -bb \
-    --define "_topdir {{output_dir | expanduser }}/zypper2/rpm-build"
+    --define "_topdir {{remote_tmp_dir | expanduser }}/zypper2/rpm-build"
     --define "_builddir %{_topdir}" \
     --define "_rpmdir %{_topdir}" \
     --define "_srcrpmdir %{_topdir}" \
-    --define "_specdir {{output_dir | expanduser}}/zypper2" \
+    --define "_specdir {{remote_tmp_dir | expanduser}}/zypper2" \
     --define "_sourcedir %{_topdir}" \
-    {{ output_dir }}/zypper2/empty.spec
+    {{ remote_tmp_dir }}/zypper2/empty.spec
   register: rpm_build_result
 
 - name: install empty rpm
   zypper:
-    name: "{{ output_dir | expanduser }}/zypper2/rpm-build/noarch/empty-1-0.noarch.rpm"
+    name: "{{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/empty-1-0.noarch.rpm"
     disable_gpg_check: yes
   register: zypper_result
 
@@ -236,13 +236,13 @@
 
 - name: extract from rpm
   zypper:
-    name: "{{ output_dir | expanduser }}/zypper2/rpm-build/noarch/empty-1-0.noarch.rpm"
+    name: "{{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/empty-1-0.noarch.rpm"
     state: installed
     disable_gpg_check: yes
-    extra_args_precommand: --root {{ output_dir | expanduser }}/testdir/
+    extra_args_precommand: --root {{ remote_tmp_dir | expanduser }}/testdir/
 
 - name: check that dir var is exist
-  stat: path={{ output_dir | expanduser }}/testdir/var
+  stat: path={{ remote_tmp_dir | expanduser }}/testdir/var
   register: stat_result
 
 - name: check that we extract rpm package in testdir folder and folder var is exist
@@ -458,25 +458,25 @@
     - name: Deploy spec files to build 2 packages with duplicate files.
       template:
         src: duplicate.spec.j2
-        dest: "{{ output_dir | expanduser }}/zypper2/duplicate{{ item }}.spec"
+        dest: "{{ remote_tmp_dir | expanduser }}/zypper2/duplicate{{ item }}.spec"
       loop: "{{ looplist }}"
 
     - name: build rpms with duplicate files
       command: |
         rpmbuild -bb \
-        --define "_topdir {{output_dir | expanduser }}/zypper2/rpm-build"
+        --define "_topdir {{remote_tmp_dir | expanduser }}/zypper2/rpm-build"
         --define "_builddir %{_topdir}" \
         --define "_rpmdir %{_topdir}" \
         --define "_srcrpmdir %{_topdir}" \
-        --define "_specdir {{output_dir | expanduser}}/zypper2" \
+        --define "_specdir {{remote_tmp_dir | expanduser}}/zypper2" \
         --define "_sourcedir %{_topdir}" \
-        {{ output_dir | expanduser }}/zypper2/duplicate{{ item }}.spec
+        {{ remote_tmp_dir | expanduser }}/zypper2/duplicate{{ item }}.spec
       loop: "{{ looplist }}"
 
     - name: install duplicate rpms
       zypper:
         name: >-
-          {{ output_dir | expanduser }}/zypper2/rpm-build/noarch/duplicate{{ item }}-1-0.noarch.rpm
+          {{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/duplicate{{ item }}-1-0.noarch.rpm
         disable_gpg_check: true
       ignore_errors: true
       register: zypper_duplicate_result
@@ -499,7 +499,7 @@
     - name: install duplicate rpms
       zypper:
         name: >-
-          {{ output_dir | expanduser }}/zypper2/rpm-build/noarch/duplicate{{ item }}-1-0.noarch.rpm
+          {{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/duplicate{{ item }}-1-0.noarch.rpm
         disable_gpg_check: true
         replacefiles: true
       ignore_errors: true