diff --git a/test/integration/targets/expect/tasks/main.yml b/test/integration/targets/expect/tasks/main.yml index ab11d669420..3170b59aecc 100644 --- a/test/integration/targets/expect/tasks/main.yml +++ b/test/integration/targets/expect/tasks/main.yml @@ -211,15 +211,24 @@ - name: test the task invocation by running ansible in command task vars: pexpect_python: "{{ hostvars['localhost']['ansible_python_interpreter'] }}" + localhost_cmd_file: "{{ output_dir }}/test_command.py" module_defaults: ansible.builtin.pip: virtualenv_python: "{{ pexpect_python }}" block: - include_role: name: setup_pexpect + apply: + delegate_to: localhost + vars: + setup_pexpect_tmpdir: "{{ output_dir }}" + + - name: copy script into output directory + copy: src=test_command.py dest={{ localhost_cmd_file }} mode=0444 + delegate_to: localhost - command: | - ansible localhost -m expect -a "command='{{pexpect_python}} {{test_command_file}} foo --quiet' responses='{\"foo\": \"bar\"}'" -vvv + ansible localhost -m expect -a "command='{{pexpect_python}} {{localhost_cmd_file}} foo --quiet' responses='{\"foo\": \"bar\"}'" -vvv delegate_to: localhost register: task_invocation diff --git a/test/integration/targets/setup_pexpect/tasks/main.yml b/test/integration/targets/setup_pexpect/tasks/main.yml index 84b7bd1ca7f..db318bf9f2a 100644 --- a/test/integration/targets/setup_pexpect/tasks/main.yml +++ b/test/integration/targets/setup_pexpect/tasks/main.yml @@ -1,19 +1,22 @@ -- name: Copy constraints file - copy: - src: constraints.txt - dest: "{{ remote_tmp_dir }}/pexpect-constraints.txt" +- vars: + pexpect_constraint_dir: "{{ setup_pexpect_tmpdir | default(remote_tmp_dir) }}" + block: + - name: Copy constraints file + copy: + src: constraints.txt + dest: "{{ pexpect_constraint_dir }}/pexpect-constraints.txt" -- name: Install pexpect with --user - pip: - name: pexpect - extra_args: '--user --constraint "{{ remote_tmp_dir }}/pexpect-constraints.txt"' - state: present - ignore_errors: yes # fails when inside a virtual environment - register: pip_user + - name: Install pexpect with --user + pip: + name: pexpect + extra_args: '--user --constraint "{{ pexpect_constraint_dir }}/pexpect-constraints.txt"' + state: present + ignore_errors: yes # fails when inside a virtual environment + register: pip_user -- name: Install pexpect - pip: - name: pexpect - extra_args: '--constraint "{{ remote_tmp_dir }}/pexpect-constraints.txt"' - state: present - when: pip_user is failed + - name: Install pexpect + pip: + name: pexpect + extra_args: '--constraint "{{ pexpect_constraint_dir }}/pexpect-constraints.txt"' + state: present + when: pip_user is failed