When I ssh into a remote server and run
env I get back the following PATH:
In contrast, when I execute the ansible command
ansible -a "env", I get the following PATH:
As can be imagined, this causes problems when trying to run
sbin commands like
ntpdate, etc. because it requires typing out the full path to the sbin command. (Yes, I know there are ansible modules that can do this, but I'm trying to solve why the PATH is getting shortened/truncated.)
Anyone know why this is happening?
EDIT: The reason I'm asking about this is that I'm following the examples in the book
Ansible for DevOps and some of the examples aren't working because of this reason.
The example I'm trying to get to work is from page 28 in the book:
$ ansible multi -s -a "service ntpd stop" $ ansible multi -s -a "ntpdate -q 0.rhel.pool.ntp.org" $ ansible multi -s -a "service ntpd start"
These commands always raise an error. But if I change them to include the full path, they work.
$ ansible multi -s -a "/sbin/service ntpd stop" $ ansible multi -s -a "/usr/sbin/ntpdate -q 0.rhel.pool.ntp.org" $ ansible multi -s -a "/sbin/service ntpd start"
Naturally, I don't want to have to type in the full path for each and every ad-hoc command I issue. (I don't know the paths of every command.)
Is there any way to get the normal path that's in my shell included with ansible? Is there a path variable that I can add to the inventory file or ansible.cfg file that will enable this to happen?