Skip to content
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

Allow 'ansible-cmdb' wrapper to be a symlink #239

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DanVanAtta
Copy link

Enhances 'ansible-cmdb' wrapper script to be able to find 'ansible-cmdb.py' when 'ansible-cmdb' is a symlink.

Currently the search paths around 'ansible-cmdb' are relative to the location of the symlink. We can use 'readlink -f'
to instead follow the symlink and search from the actual location of 'ansible-cmdb'

The use-case where this comes up is we want to add 'ansible-cmdb' to the path. To do this we are creating a symlink
from '/bin/ansible-cmdb' to its actual location. After this update, the command '/bin/ansible-cmdb' works as expected
because the wrapper script follows the symlink.


This update is backward compatible. If '$0' is a file, then "readlink -f" will return the canonical file name of that file (existing behavior), otherwise if '$0' is a symlink then we recursively follow every symlink of '$0'.

For convenience, the man info on the '-f' flag:

     -f, --canonicalize
              canonicalize by following every symlink in every component of the given name recursively;
              all but the last component must exist

And the man info of 'readlink':

NAME
       readlink - print resolved symbolic links or canonical file names

Enhances 'ansible-cmdb' wrapper script to be able to find 'ansible-cmdb.py' when 'ansible-cmdb' is a symlink.

Currently the search paths around 'ansible-cmdb' are relative to the location of the symlink. We can use 'readlink -f'
to instead follow the symlink and search from the actual location of 'ansible-cmdb'

The use-case where this comes up is we want to add 'ansible-cmdb' to the path. To do this we are creating a symlink
from '/bin/ansible-cmdb' to its actual location. After this update,  the command '/bin/ansible-cmdb' works as expected
because the wrapper script follows the symlink.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant