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
Hardlink follow #34228
base: devel
Are you sure you want to change the base?
Hardlink follow #34228
Conversation
@odra what were the failures you mentioned that prevent it from being in the file target? |
lib/ansible/modules/files/file.py
Outdated
@@ -422,6 +422,8 @@ def main(): | |||
else: | |||
try: | |||
if state == 'hard': | |||
if follow and os.path.islink(b_src): | |||
b_src = os.readlink(b_src) |
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.
islink and readlink only works with symlinks. Also, this makes no sense for hardlinks, they don't have a canonical source, both entries ARE the file.
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.
It is failing to create a hard link when using a symlink path as its src, that's why I used those functions to retrieve the symlink original path.
@caphrim007 the first error I get is this one:
It creates an empty file with a different permission than the expected one, if I comment that particular check, it fails on this step:
|
Hello @bcoca I have removed the hard link so the change is applied for both link types. |
/azp run |
Pull request contains merge conflicts. |
SUMMARY
Uses
os.readlink
to retrieve the link's full path when hard linking a soft link (usingfollow: true
).Fixes #33911
ISSUE TYPE
Bugfix Pull Request
COMPONENT NAME
File
ANSIBLE VERSION
ADDITIONAL INFORMATION
I created an additional task in the module's integration test, sample usage:
Note: not sure if this is the best approach to test this, I tried to use the file role test (main.yml) but it failed a couple of times to me + this test felt like it should be an isolated test case on its own.