'passwordless sudo still requires password in capistrano

In capistrano script

set :stage, :production
set :branch, 'master'
server 'lion.example.jp', user: 'ubuntu', roles: %w(app), 
set :user, "ubuntu"

namespace :deploy do
    desc 'Collec Static Files'
    task :collectImg do
        on roles(:app) do
            execute :sudo,"curl -X GET --unix-socket /run/control.unit.sock http://localhost/control/applications/myapp/restart"

        end
    end
    after :publishing, :collectImg
end

it shows error below

DEBUG [7fade908]    sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

However I set passwordless sudo for user ubuntu

Why does it still require password?

Or can I solve this?



Solution 1:[1]

I think you need to set the "ubuntu" user in capistrano, like so.

I see that it's in the server block, but maybe give this a try as well.

set :user, "ubuntu"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dalemonaco