Better way to specify path to binary?

14 views
Skip to first unread message

James Lucas

unread,
Sep 4, 2015, 9:35:00 PM9/4/15
to Ansible Project
Hello: I've been using the 'pkgutil'  extras module to install packages on some Solaris machines. Roles
I've been working with that use the module will fail if '/opt/csw/bin' is not in the servers' PATH environment variable.
It's easy enough to work around by doing something like this in roles that depend on it:

- name: Install Nagios NRPE Server [Solaris]
  pkgutil: name=CSWnrpe state=present
  environment:
    PATH: "{{ansible_env.PATH}}:/opt/csw/bin"

My question, though, is whether it would make sense to also supply a full path as a default in the module itself --
something like:

if not distutils.spawn.find_executable(cmd): 
    cmd = '/opt/csw/bin/pkgutil'

A quick look around similar modules suggest that it's normal to supply a full path to the binary... for instance, in
the 'yum' module:

yumbin='/usr/bin/yum'

Given that 'pkgutil' is by default installed into a location ('/opt/csw/bin') that is not 
in the system's default PATH, wouldn't it make sense to have the module either:

a) supply a default, rather than just assuming it's available through the PATH?

or:

b) Just specify a full path to begin with, as in the 'yum' example above?

I myself prefer (a). I'd gladly submit a pull request for this if it seems like a good idea.

Thanks,
James
Reply all
Reply to author
Forward
0 new messages