Reputation: 1861
I am deploying my Rails app with Capistrano 3. I've struggled all the way through, but now when everything is almost done I cannot create a symlink through a Capistrano task.
With Capistrano 2.x I could easily do it with the following line:
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
Now Capistrano 3 has advocated passwordless sudo
approach as described here.
I've added the following line to sudoers
deployer ALL=NOPASSWD:/etc/init.d/sites-enabled/application-name
and changed my command in Capistrano task to:
execute :sudo, :ln, "-nfs", "#{current_path}/nginx.conf /etc/nginx/sites-enabled/#{fetch(:application)}"
What am I missing? Is the line I added to sudoers
correct?
Thank you!
Upvotes: 1
Views: 1427
Reputation: 1748
Alex, when you edit sudoers
, you should list commands you would like to execute (not the files you'd like to symlink).
Thus, the line in sudoers
should be as follows:
deployer ALL=NOPASSWD:/bin/ln -nfs /current/path/config/nginx.conf /etc/nginx/sites-enabled/application-name
You can also make it more general:
deployer ALL=NOPASSWD:/bin/ln -nfs /current/path/* /etc/nginx/sites-enabled/*
but it will be less secure.
Upvotes: 3