From d2f524fb27ba2b4437c525724cac9d472e64cc36 Mon Sep 17 00:00:00 2001
From: Felix Fontein <felix@fontein.de>
Date: Fri, 19 Oct 2018 09:00:34 +0200
Subject: [PATCH] Use {{ ansible_python.executable }} instead of python in
 integration tests. (#47340)

---
 .../targets/certificate_complete_chain/tasks/main.yml         | 2 +-
 .../lookup_hashi_vault/playbooks/test_lookup_hashi_vault.yml  | 2 +-
 test/integration/targets/pip/tasks/pip.yml                    | 4 ++--
 test/integration/targets/setup_acme/tasks/main.yml            | 2 +-
 test/integration/targets/setup_openssl/tasks/main.yml         | 4 ++--
 test/integration/targets/sts_assume_role/tasks/main.yml       | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/integration/targets/certificate_complete_chain/tasks/main.yml b/test/integration/targets/certificate_complete_chain/tasks/main.yml
index 5248db68ba3..9fed94c2d55 100644
--- a/test/integration/targets/certificate_complete_chain/tasks/main.yml
+++ b/test/integration/targets/certificate_complete_chain/tasks/main.yml
@@ -1,6 +1,6 @@
 ---
 - name: register cryptography version
-  command: python -c 'import cryptography; print(cryptography.__version__)'
+  command: "{{ ansible_python.executable }} -c 'import cryptography; print(cryptography.__version__)'"
   register: cryptography_version
 
 - block:
diff --git a/test/integration/targets/lookup_hashi_vault/playbooks/test_lookup_hashi_vault.yml b/test/integration/targets/lookup_hashi_vault/playbooks/test_lookup_hashi_vault.yml
index 26b11f22e36..bb3a136ae5e 100644
--- a/test/integration/targets/lookup_hashi_vault/playbooks/test_lookup_hashi_vault.yml
+++ b/test/integration/targets/lookup_hashi_vault/playbooks/test_lookup_hashi_vault.yml
@@ -1,7 +1,7 @@
 - hosts: testhost
   tasks:
     - name: register pyOpenSSL version
-      command: python -c 'import OpenSSL; print(OpenSSL.__version__)'
+      command: "{{ ansible_python.executable }} -c 'import OpenSSL; print(OpenSSL.__version__)'"
       register: pyopenssl_version
 
     - name: Test lookup hashi_vault
diff --git a/test/integration/targets/pip/tasks/pip.yml b/test/integration/targets/pip/tasks/pip.yml
index e34e932d1ca..2c650eab385 100644
--- a/test/integration/targets/pip/tasks/pip.yml
+++ b/test/integration/targets/pip/tasks/pip.yml
@@ -256,11 +256,11 @@
     extra_args: --user --upgrade --root {{ output_dir }}/pip_root
 
 - name: register python_site_lib
-  command: 'python -c "import site; print(site.USER_SITE)"'
+  command: '{{ ansible_python.executable }} -c "import site; print(site.USER_SITE)"'
   register: pip_python_site_lib
 
 - name: register python_user_base
-  command: 'python -c "import site; print(site.USER_BASE)"'
+  command: '{{ ansible_python.executable }} -c "import site; print(site.USER_BASE)"'
   register: pip_python_user_base
 
 - name: run test module
diff --git a/test/integration/targets/setup_acme/tasks/main.yml b/test/integration/targets/setup_acme/tasks/main.yml
index 670a4fb8e22..6f4f2ec02bc 100644
--- a/test/integration/targets/setup_acme/tasks/main.yml
+++ b/test/integration/targets/setup_acme/tasks/main.yml
@@ -4,7 +4,7 @@
   register: openssl_version
 
 - name: register cryptography version
-  command: python -c 'import cryptography; print(cryptography.__version__)'
+  command: "{{ ansible_python.executable }} -c 'import cryptography; print(cryptography.__version__)'"
   register: cryptography_version
 
 - debug: msg="ACME test container IP is {{ acme_host }}; OpenSSL version is {{ openssl_version.stdout }}; cryptography version is {{ cryptography_version.stdout }}"
diff --git a/test/integration/targets/setup_openssl/tasks/main.yml b/test/integration/targets/setup_openssl/tasks/main.yml
index d56ad838864..0ccef71cc5d 100644
--- a/test/integration/targets/setup_openssl/tasks/main.yml
+++ b/test/integration/targets/setup_openssl/tasks/main.yml
@@ -21,7 +21,7 @@
   when:  ansible_os_family == 'Darwin'
 
 - name: register pyOpenSSL version
-  command: python -c 'import OpenSSL; print(OpenSSL.__version__)'
+  command: "{{ ansible_python.executable }} -c 'import OpenSSL; print(OpenSSL.__version__)'"
   register: pyopenssl_version
 
 - name: register openssl version
@@ -29,5 +29,5 @@
   register: openssl_version
 
 - name: register cryptography version
-  command: python -c 'import cryptography; print(cryptography.__version__)'
+  command: "{{ ansible_python.executable }} -c 'import cryptography; print(cryptography.__version__)'"
   register: cryptography_version
diff --git a/test/integration/targets/sts_assume_role/tasks/main.yml b/test/integration/targets/sts_assume_role/tasks/main.yml
index 687619c61c5..5fc0e4dc156 100644
--- a/test/integration/targets/sts_assume_role/tasks/main.yml
+++ b/test/integration/targets/sts_assume_role/tasks/main.yml
@@ -16,7 +16,7 @@
           print(response['Account'])
 
     - name: get the aws account id
-      command: python "{{ output_dir }}/sts.py"
+      command: "{{ ansible_python.executable }} '{{ output_dir }}/sts.py'"
       environment:
         AWS_ACCESS_KEY_ID: "{{ aws_access_key }}"
         AWS_SECRET_ACCESS_KEY: "{{ aws_secret_key }}"