issue #409: Pythonize run_ansible_playbook.sh

And add git_basedir extra variable.
issue260
David Wilson 6 years ago
parent 48e8f1f7aa
commit 5b916fc556

@ -63,5 +63,5 @@ with ci_lib.Fold('job_setup'):
with ci_lib.Fold('ansible'):
run('/usr/bin/time ./run_ansible_playbook.sh all.yml -i "%s" %s',
run('/usr/bin/time ./run_ansible_playbook.py all.yml -i "%s" %s',
HOSTS_DIR, ' '.join(sys.argv[1:]))

@ -13,7 +13,7 @@ demonstrator for what does and doesn't work.
See `../image_prep/README.md`.
## `run_ansible_playbook.sh`
## `run_ansible_playbook.py`
This is necessary to set some environment variables used by future tests, as
there appears to be no better way to inject them into the top-level process
@ -22,7 +22,7 @@ environment before the Mitogen connection process forks.
## Running Everything
`ANSIBLE_STRATEGY=mitogen_linear ./run_ansible_playbook.sh all.yml`
`ANSIBLE_STRATEGY=mitogen_linear ./run_ansible_playbook.py all.yml`
## `hosts/` and `common-hosts`

@ -1,15 +0,0 @@
#!/bin/bash
# Wrap ansible-playbook, setting up some test of the test environment.
# Used by delegate_to.yml to ensure "sudo -E" preserves environment.
export I_WAS_PRESERVED=1
export MITOGEN_MAX_INTERPRETERS=3
if [ "${ANSIBLE_STRATEGY:0:7}" = "mitogen" ]
then
EXTRA='{"is_mitogen": true}'
else
EXTRA='{"is_mitogen": false}'
fi
exec ~/src/cpython/venv/bin/ansible-playbook -e "$EXTRA" -e ansible_python_interpreter=/Users/dmw/src/cpython/venv/bin/python2.7 "$@"

@ -1,3 +1,3 @@
#!/bin/bash
export ANSIBLE_STRATEGY=mitogen_linear
exec ./run_ansible_playbook.sh "$@"
exec ./run_ansible_playbook.py "$@"

@ -0,0 +1,27 @@
#!/usr/bin/env python
# Wrap ansible-playbook, setting up some test of the test environment.
import json
import os
import sys
# Used by delegate_to.yml to ensure "sudo -E" preserves environment.
os.environ['I_WAS_PRESERVED'] = '1'
# Used by LRU tests.
os.environ['MITOGEN_MAX_INTERPRETERS'] = '3'
extra = {
'is_mitogen': os.environ.get('ANSIBLE_STRATEGY', '').startswith('mitogen'),
'git_basedir': os.path.dirname(
os.path.abspath(
os.path.join(__file__, '..', '..')
)
)
}
args = ['ansible-playbook']
args += ['-e', json.dumps(extra)]
args += sys.argv[1:]
os.execvp(args[0], args)

@ -1,15 +0,0 @@
#!/bin/bash
# Wrap ansible-playbook, setting up some test of the test environment.
# Used by delegate_to.yml to ensure "sudo -E" preserves environment.
export I_WAS_PRESERVED=1
export MITOGEN_MAX_INTERPRETERS=3
if [ "${ANSIBLE_STRATEGY:0:7}" = "mitogen" ]
then
EXTRA='{"is_mitogen": true}'
else
EXTRA='{"is_mitogen": false}'
fi
exec ansible-playbook -e "$EXTRA" "$@"
Loading…
Cancel
Save