|
|
|
@ -208,15 +208,22 @@
|
|
|
|
|
- "non_zero_result.failed"
|
|
|
|
|
- "non_zero_result.msg == 'non-zero return code'"
|
|
|
|
|
|
|
|
|
|
- name: run ansible via command to validate the invocation
|
|
|
|
|
command: |
|
|
|
|
|
ansible localhost -m expect -a "{{ module_args }}" -vvv
|
|
|
|
|
- name: test the task invocation by running ansible in command task
|
|
|
|
|
vars:
|
|
|
|
|
module_args: |
|
|
|
|
|
command='{{ansible_python_interpreter}} {{test_command_file}} foo --quiet' responses='{\"foo\": \"bar\"}'
|
|
|
|
|
register: task_invocation
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- "'invocation' in task_invocation.stdout"
|
|
|
|
|
- "'bar' not in task_invocation.stdout"
|
|
|
|
|
pexpect_python: "{{ hostvars['localhost']['ansible_python_interpreter'] }}"
|
|
|
|
|
module_defaults:
|
|
|
|
|
ansible.builtin.pip:
|
|
|
|
|
virtualenv_python: "{{ pexpect_python }}"
|
|
|
|
|
block:
|
|
|
|
|
- include_role:
|
|
|
|
|
name: setup_pexpect
|
|
|
|
|
|
|
|
|
|
- command: |
|
|
|
|
|
ansible localhost -m expect -a "command='{{pexpect_python}} {{test_command_file}} foo --quiet' responses='{\"foo\": \"bar\"}'" -vvv
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
register: task_invocation
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- "'invocation' in task_invocation.stdout"
|
|
|
|
|
- "'bar' not in task_invocation.stdout"
|
|
|
|
|