issue #591: ansible: restore CWD prior to AnsibleModule initialization.
parent
92ac716f0d
commit
0b7fd3f290
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/python
|
||||
# #591: call os.getcwd() before AnsibleModule ever gets a chance to fix up the
|
||||
# process environment.
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
import json
|
||||
except ImportError:
|
||||
import simplejson as json
|
||||
|
||||
print(json.dumps({
|
||||
'cwd': os.getcwd()
|
||||
}))
|
@ -0,0 +1,20 @@
|
||||
# #591: process CWD is not reset before start of module execution. This is
|
||||
# usually fine, except for modules importing setuptools early, which attempts
|
||||
# to call getcwd() before AnsibleModule has had a chance to clean up the
|
||||
# process environment.
|
||||
|
||||
- hosts: test-targets
|
||||
tasks:
|
||||
- meta: end_play
|
||||
when: not is_mitogen
|
||||
|
||||
- custom_python_run_script:
|
||||
script: |
|
||||
import os
|
||||
os.chdir(module.tmpdir)
|
||||
|
||||
# Will crash if process has a nonexistent CWD.
|
||||
- custom_python_os_getcwd:
|
||||
script: |
|
||||
import os
|
||||
self._connection.get_chain().call(os.getcwd)
|
Loading…
Reference in New Issue