diff --git a/examples/playbook/ansible.cfg b/examples/playbook/ansible.cfg index 2b3c6193..e9ecb706 100644 --- a/examples/playbook/ansible.cfg +++ b/examples/playbook/ansible.cfg @@ -7,6 +7,9 @@ library = modules retry_files_enabled = False forks = 50 +# Required by runner__remote_tmp.yml +remote_tmp = ~/.ansible/mitogen-tests/ + [ssh_connection] ssh_args = -o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s pipelining = True diff --git a/examples/playbook/modules/bash_return_paths.sh b/examples/playbook/modules/bash_return_paths.sh new file mode 100755 index 00000000..d6282084 --- /dev/null +++ b/examples/playbook/modules/bash_return_paths.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# I am an Ansible WANT_JSON module that returns the paths to its argv[0] and +# args file. + +INPUT="$1" + +[ ! -r "$INPUT" ] && { + echo "Usage: $0 " >&2 + exit 1 +} + +echo "{" +echo " \"changed\": false," +echo " \"msg\": \"Here is my input\"," +echo " \"input\": [$(< $INPUT)]," +echo " \"argv0\": \"$0\"," +echo " \"argv1\": \"$1\"" +echo "}" diff --git a/examples/playbook/runner.yml b/examples/playbook/runner.yml index 4a2fed81..51583ba3 100644 --- a/examples/playbook/runner.yml +++ b/examples/playbook/runner.yml @@ -9,3 +9,4 @@ - import_playbook: runner__custom_python_json_args_module.yml - import_playbook: runner__custom_python_new_style_module.yml - import_playbook: runner__custom_python_want_json_module.yml +- import_playbook: runner__remote_tmp.yml diff --git a/examples/playbook/runner__remote_tmp.yml b/examples/playbook/runner__remote_tmp.yml new file mode 100644 index 00000000..74f18480 --- /dev/null +++ b/examples/playbook/runner__remote_tmp.yml @@ -0,0 +1,16 @@ +# +# The ansible.cfg remote_tmp setting should be copied to the target and used +# when generating temporary paths created by the runner.py code executing +# remotely. +# +- hosts: all + gather_facts: true + tasks: + - bash_return_paths: + register: output + + - assert: + that: output.argv0.startswith('%s/.ansible/mitogen-tests/' % ansible_user_dir) + + - assert: + that: output.argv1.startswith('%s/.ansible/mitogen-tests/' % ansible_user_dir)