New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module basic.py to create parent dirs of tmpdir if needed #40201
Conversation
Code looks good. I'd assert whether makedirs is called and also add a case where the path already exists (and assert that makedirs is not called in that case). |
@@ -51,7 +51,16 @@ class TestAnsibleModuleTmpDir: | |||
def test_tmpdir_property(self, am, monkeypatch, expected): | |||
def mock_mkdtemp(prefix, dir): | |||
return os.path.join(dir, prefix) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makedirs_called = 0
def mock_makedirs(path, mode):
makedirs_called += 1
expected = os.path.expanduser(os.path.expandvars(am._remote_tmp))
assert path == expected
assert mode = 0o700
return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And then after line 71:
assert makedirs_called == 1
4155ae8
to
d4be23c
Compare
From #40168 (comment)
|
SUMMARY
When pipelining is enabled and the path at
remote_tmp
does not already exists,module.tmpdir
will fail to create the tmp directory. This change will ensure the parent dirs exists before creating that module tmp directory.Fixes #40168
ISSUE TYPE
COMPONENT NAME
module_utils/basic.py
ANSIBLE VERSION