ansible: better emulate _low_level_execute_command()
Still needs a ton of work to emulate argument handling, shell selection, and output emulation in every case. Unsurprisingly, Ansible documents none of this.wip-fakessh-exit-status
parent
5855f1739f
commit
f3315fc172
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
# Verify the behaviour of _low_level_execute_command().
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
|
||||||
|
# "echo -en" to test we actually hit bash shell too.
|
||||||
|
- name: Run raw module without sudo
|
||||||
|
raw: 'echo -en $((1 + 1))'
|
||||||
|
register: raw
|
||||||
|
|
||||||
|
- name: Verify raw module output.
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'raw.rc == 0'
|
||||||
|
- 'raw.stdout_lines == ["2"]'
|
||||||
|
- 'raw.stdout == "2"'
|
||||||
|
|
||||||
|
- name: Run raw module with sudo
|
||||||
|
become: true
|
||||||
|
raw: 'whoami'
|
||||||
|
register: raw
|
||||||
|
|
||||||
|
# Can't test stdout because TTY inserts \r in Ansible version.
|
||||||
|
- debug: msg={{raw}}
|
||||||
|
- name: Verify raw module output.
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- 'raw.rc == 0'
|
||||||
|
- 'raw.stdout_lines == ["root"]'
|
Loading…
Reference in New Issue