I'm trying to install pacaur using a script via Ansible:
curl -s https://gist.githubusercontent.com/Tadly/0e65d30f279a34c33e9b/raw/pacaur_install.sh | bash
With the ansible command
ansible 192.168.1.2 -m shell -a "curl -s https://gist.githubusercontent.com/Tadly/0e65d30f279a34c33e9b/raw/pacaur_install.sh | bash"
But I get pacman
complaining about pod2man
missing. It seems to be a problem with the PATH of ansible command.
Running the command on the machine directly using ssh works correctly.
Here's the output of: ansible -m all shell -a 'echo $PATH'
localhost | SUCCESS | rc=0 >>
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
192.168.1.2| SUCCESS | rc=0 >>
/usr/bin:/bin:/usr/sbin:/sbin
As reported in comments, the problem is that when switching users sudo
sanitizes PATH
(see this ServerFault question for details).
The ad-hoc command to export the local PATH
to hosts that I propose seems a bit hacky but it works (it uses the --extra-vars
option of ansible
command together with Jinja's variable injection)
ansible all -m shell -a "export PATH={{path}}; curl -s https://gist.githubusercontent.com/Tadly/0e65d30f279a34c33e9b/raw/pacaur_install.sh | bash" -e path=$PATH
You could also use the {{ lookup('env', 'PATH') }}
to forward the PATH
.