I have an Ansible task based on https://github.com/al3x/sovereign/blob/master/roles/tarsnap/tasks/tarsnap.yml#L2 that keeps failing when it should succeed.
I used to run the role with
ansible_ssh_user=root, but recently switched to using a non-root user that has passwordless sudo rights and then calling
become in my playbooks.
However, now the Ansible task fails even though I've specified
become=true. Tarsnap is already installed, but the task still returns
stderr: /bin/sh: tarsnap: command not found. I think it's because of something around
sudo that I don't quite understand.
When I manually ssh into the server as this non-root user and run
sudo tarsnap --version | grep 1.0.35 --color=never, I get
sudo: tarsnap: command not found. But if I SSH in as root, that same command gives me
Similarly, when I run
sudo -i tarsnap --version | grep 1.0.35 --color=never (note the -i), I get
I am using CentOS 7.
1) Why are the results different for
2) How do I fix my Ansible task?