How to set the path for sudo?

Hello,
I am trying to use ansible 1.2 with Solaris 10 systems. Sudo is installed and configured on the target systems, but the binary is not in the path variable (it’s /usr/local/bin/sudo).
Of course i could connect to every Solaris 10 server and edit the path…
But (in my opinion) it’s better to reference the path within an ansible playbook. Is it possible to tell ansible, where it has to search for the sudo binary?

Currently the sudo executable called can be set in ansible.cfg, though this is there to support those that wish to use other sudo compatible implementations, and is global.

It is not possible to set this variable on a per inventory record basis, though it would be possible to tweak Ansible to allow this (pull requests would be welcome, if not, file a ticket).

Ultimately you do need to edit the path right now.

I’m not sure if other folks on Solaris 10 have had this problem, that seems pretty unfortunate that the OS developers wouldn’t bother putting sudo in the user’s path.

Of course, changing the default profile would be the best solution. Luckily I can do this with ansible, by changing the sudo-path inside ansible.cfg temporary.

This should work. Thank you.

Hi again,
I recently catched that running an command directly with ssh won’t load the profile (e.g. ‘ssh host sudo command’, and that’s what ansible does). It seems like the environment variables are taken from /etc/default/login. In my case, sudo is placed in /usr/local/bin and that is not in the path by default.
‘ssh host echo $PATH’ just showed up /usr/bin and /bin. So adding “PATH=/usr/bin:/bin/:/usr/local/bin” to /etc/default/login seems to be the way to make sudo working with direct ssh connect.

How did you manage this problem? I just feel like I am doing something the wrong way O_o

You should not rely on remove environment variables for centralized configuration management – trusting the user environment is sane is not a good way to get a reliable configuration.

That being said, look into the environment parameter in Ansible if you wish to forceable push down environment settings like an HTTP_PROXY value.

Addind the environment to every task wouldn’t be a better solution in my optionen.

How are other users manage sudo not beeing in the standard path?

My apologies.

I didn’t suggest that for setting the path to sudo, but rather for cases where sudo was eating your environment.

You can control the path to sudo in ansible.cfg

Configuring the path for sudo in ansible.cfg is a suitable way for an homogenous inventory. But not if you have various operating systems with sudo in different paths and you want to manage everything with one call of an enormous playbook.

Yes, I agree that’s suboptimal in the case where they are different.

I’m open to patches that would allow it to be configured as an inventory variable also.

We occasionally do that for parameters we add first and then decide they should be specific host tunable. (See discussion also about per group host key checking configuration).

If this is not something you’d like to (or feel comfortable) working on, can you open a feature request in github so we don’t forget?

Thanks!

–Michael