FrancisV
FrancisV

Reputation: 1749

Get the full path of the symlink target in Ansible

How do I get the full path of a symlink target in Ansible? I'm trying to cleanup a folder--delete files older than x number of days but I don't want to remove the target of a particular file symlink. My plan is to get the symlink target and then use the value as an exclude target when using the find module.

The symlink target changes from time to time. I tried using the stat module but it doesn't solve my requirement.

Upvotes: 6

Views: 7915

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68329

stat module returns lnk_source and lnk_target which should do the trick.


Pay attention to confusing names:

For the actual SOURCE of the symlink, well, it's just path.

Upvotes: 11

Related Questions