Envoy Task Runner: run command that requires sudo access

1.4k views Asked by At

I am using https://laravel.com/docs/5.4/envoy as a deployment tool. In the Envoy.blade.php, I have command that requires sudo access for example:-

chmod 777 -R storage/
chmod 777 -R bootstrap/cache

These commands fails with an error saying operation not permitted. How can we resolve this?

2

There are 2 answers

0
Dave Carruthers On

To run those commands as sudo try the following:

echo "{{ $password }}" | sudo -S chmod 777 -R storage/
echo "{{ $password }}" | sudo -S chmod 777 -R bootstrap/cache

Obviously you'll need to pass the sudo password into the envoy run command.

envoy run mytask --password=mypass

Tested on Ubuntu server 16.04 & 17.04

0
Sergey Andrianov On

I changed the following configuration on the server

sudo visudo

and add

username ALL=(ALL) NOPASSWD: ALL

All commands can now be executed without entering a password

You can also specify individual commands

username ALL=(username) NOPASSWD:/etc/init.d/apache2 reload