From 8d96af2df5a4f9452140fd4b16ed4b8b45526096 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 29 Mar 2019 01:19:51 -0700 Subject: [PATCH] Use correct python for -c invocations in tests. (#54577) * Use correct python for -c invocations in tests. * Only set releasever when available. --- test/integration/targets/aws_kms/tasks/main.yml | 2 +- test/integration/targets/jinja2_native_types/runtests.yml | 2 +- test/integration/targets/script/tasks/main.yml | 2 +- test/integration/targets/user/tasks/main.yml | 2 +- test/integration/targets/xml/tasks/main.yml | 2 +- test/integration/targets/yum/tasks/yuminstallroot.yml | 6 ++++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/test/integration/targets/aws_kms/tasks/main.yml b/test/integration/targets/aws_kms/tasks/main.yml index b8b73676a66..12b04b2b06d 100644 --- a/test/integration/targets/aws_kms/tasks/main.yml +++ b/test/integration/targets/aws_kms/tasks/main.yml @@ -108,7 +108,7 @@ no_log: True - name: get ARN of calling user - command: python -c 'import boto3,json; sts = boto3.client("sts"); print json.dumps(sts.get_caller_identity())' + command: "{{ ansible_python_interpreter }} -c 'import boto3, json; sts = boto3.client(\"sts\"); print json.dumps(sts.get_caller_identity())'" changed_when: False environment: "{{ aws_environment }}" register: sts_get_caller_results diff --git a/test/integration/targets/jinja2_native_types/runtests.yml b/test/integration/targets/jinja2_native_types/runtests.yml index 9c61e699477..efcdb7a5723 100644 --- a/test/integration/targets/jinja2_native_types/runtests.yml +++ b/test/integration/targets/jinja2_native_types/runtests.yml @@ -32,7 +32,7 @@ yaml_none: ~ tasks: - name: check jinja version - shell: python -c 'import jinja2; print(jinja2.__version__)' + command: "{{ ansible_python_interpreter }} -c 'import jinja2; print(jinja2.__version__)'" register: jinja2_version - name: make sure jinja is the right version diff --git a/test/integration/targets/script/tasks/main.yml b/test/integration/targets/script/tasks/main.yml index 441d7406912..f1746f7c485 100644 --- a/test/integration/targets/script/tasks/main.yml +++ b/test/integration/targets/script/tasks/main.yml @@ -226,7 +226,7 @@ - name: Run script with shebang omitted script: no_shebang.py args: - executable: python + executable: "{{ ansible_python_interpreter }}" register: _shebang_omitted_test tags: - noshebang diff --git a/test/integration/targets/user/tasks/main.yml b/test/integration/targets/user/tasks/main.yml index 3923c0d79c8..591efba2d32 100644 --- a/test/integration/targets/user/tasks/main.yml +++ b/test/integration/targets/user/tasks/main.yml @@ -255,7 +255,7 @@ mode = oct(0o777 & ~umask) print(str(mode).replace('o', '')) args: - executable: "{{ ansible_facts.python.executable }}" + executable: "{{ ansible_python_interpreter }}" register: user_login_defs_umask - name: validate that user home dir is created diff --git a/test/integration/targets/xml/tasks/main.yml b/test/integration/targets/xml/tasks/main.yml index ca47f1be047..66cdb8599ec 100644 --- a/test/integration/targets/xml/tasks/main.yml +++ b/test/integration/targets/xml/tasks/main.yml @@ -15,7 +15,7 @@ # when: ansible_os_family == "Darwin" - name: Get lxml version - command: python -c 'from lxml import etree; print(".".join(str(v) for v in etree.LXML_VERSION))' + command: "{{ ansible_python_interpreter }} -c 'from lxml import etree; print(\".\".join(str(v) for v in etree.LXML_VERSION))'" register: lxml_version - name: Set lxml capabilities as variables diff --git a/test/integration/targets/yum/tasks/yuminstallroot.yml b/test/integration/targets/yum/tasks/yuminstallroot.yml index 13fc3002004..affd0d8be9b 100644 --- a/test/integration/targets/yum/tasks/yuminstallroot.yml +++ b/test/integration/targets/yum/tasks/yuminstallroot.yml @@ -22,13 +22,15 @@ mode: 0755 - name: get yum releasever - shell: python -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar["releasever"])' | tail -n 1 + command: "{{ ansible_python_interpreter }} -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar[\"releasever\"])'" register: releasever + ignore_errors: yes - name: Populate directory copy: - content: "{{ releasever.stdout }}\n" + content: "{{ releasever.stdout_lines[-1] }}\n" dest: "/{{ yumroot.stdout }}/etc/yum/vars/releasever" + when: releasever is successful # This will drag in > 200 MB. - name: attempt installroot