Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudo and PTY mode #1154

Closed
vladdnepr opened this issue Apr 7, 2017 · 37 comments
Closed

Sudo and PTY mode #1154

vladdnepr opened this issue Apr 7, 2017 · 37 comments

Comments

@vladdnepr
Copy link

vladdnepr commented Apr 7, 2017

Q A
Issue Type Bug
Deployer Version 4.3
Local Machine OS Linux work 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Remote Machine OS Linux release 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

Description

After commit 157a8d0
deploy always wait

It reproduced on 2 different dev PC and 2 different servers

Without pty option all works fine, but sudo not

Steps to reproduce

Im add echo to this place and get full command

Before commit changes:

$ ./vendor/bin/dep date production -vvv
➤ Executing task date
[production] > date
Execute: ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=5 -o ControlPath='~/.ssh/deployer_mux_deployer@SOME_IP:22' -p '22' -i '/home/vlad/.ssh/id_rsa' -t 'deployer@SOME_IP' 'date'[production] < Fri Apr  7 10:23:16 EDT 2017
[production] < Shared connection to SOME_IP closed.
• done on [production]
✔ Ok [147ms]

After commit changes:

$ ./vendor/bin/dep date production -vvv
➤ Executing task date
[production] > date
Execute: ssh -A -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ControlMaster=auto -o ControlPersist=5 -o ControlPath='~/.ssh/deployer_mux_deployer@SOME_IP:22' -p '22' -i '/home/vlad/.ssh/id_rsa' -t 'deployer@SOME_IP' bash -s

and wait

Content of deploy.php

<?php
namespace Deployer;

require 'recipe/common.php';

// Configuration

set('ssh_type', 'native');
set('ssh_multiplexing', true);

set('repository', 'https://github.com/user/repo.git');
set('shared_files', []);
set('shared_dirs', []);
set('writable_dirs', []);

// Servers

task('date', function () {
    run("date");
});

server('production', 'SOME_IP')
    ->user('deployer')
    ->identityFile()
    ->stage('production')
    ->set('deploy_path', '/home/deployer/test')
    ->pty(true);
@antonmedv
Copy link
Member

Without pty option all works fine

Use it.

Or migrate to v5. There pty was refactored and now it's possible to use correctly.

@vladdnepr
Copy link
Author

okay, but im need sudo. for example for reload php-fpm

When will the release be?

@antonmedv
Copy link
Member

Use sudores if you need

@jordisala1991
Copy link
Contributor

is there a way to use ->pty(true) using yaml config?

I tried already pty: true but it doesn't work

@antonmedv
Copy link
Member

Using pty is bad practice

@vladdnepr
Copy link
Author

Yes, bad. But sudo works only with pty, but with pty always deploy is waiting. Deadlock happen

@antonmedv
Copy link
Member

What about sudores?

@vladdnepr
Copy link
Author

Maybe you mean sudoers?

@antonmedv
Copy link
Member

Yes, you are understand me.

@antonmedv antonmedv changed the title Deploy always wait Sudo and PTY mode Apr 10, 2017
@vladdnepr
Copy link
Author

Im use sudoers. Sudoers allow execute sudo without password, but only that. sudo must be used to restart php for example, and without sudo not work.

@antonmedv
Copy link
Member

So does it works without pty?

@vladdnepr
Copy link
Author

No. See more #953

@antonmedv
Copy link
Member

I see :) Fixed in v5)))

@vladdnepr
Copy link
Author

okay. When will the release be?

@antonmedv
Copy link
Member

I hope next week. Need to write some docs.

@itelmenko
Copy link

I have a similar problem in deployer 5 beta 2. Now with set('git_tty', true);
Deployer is veeeery slow.
Before each little step it does "ssh multiplexing initialization".

Also does anybody know why we need this command "sudo systemctl restart php-fpm.service"?
Deployer makes symlink form folder "current" to current release folder.
Why we need restart php-fpm if webroot is current/public?

@vladdnepr
Copy link
Author

Php restart need because php fpm in production mode use opcode cache. Without restart php used old version of your code

@itelmenko
Copy link

Thank you @vladdnepr .

@itelmenko
Copy link

May be we need tty option for command "sudo systemctl restart php-fpm.service" only?
Not for all commands.
I am not sure why deployer is very slow with tty option...

@itelmenko
Copy link

@antonmedv , What do you think?

@vladdnepr
Copy link
Author

Make pull request with some option. This option must enable analyze command for sudo and if it's present - enable pty only for that command. By default this option must be disabled. This is my solution.

@itelmenko
Copy link

@vladdnepr Do you have same problem for version 5?

@vladdnepr
Copy link
Author

No. Im waiting v5 release

@antonmedv
Copy link
Member

@itelmenko this is an example. You can add tty to run as options:

run('...', ['tty' => true]);

git_tty affects only git clone, not all commands.

@antonmedv
Copy link
Member

This option must enable analyze command for sudo and if it's present - enable pty only for that command.

This is really complicated stuff what leads to bugs. There a plenty of sudo prompts to parse.

@itelmenko
Copy link

Thank you @antonmedv

git_tty affects only git clone, not all commands.

O-ho-ho, I am really inattentive

@vladdnepr
Copy link
Author

@antonmedv ok, your variant with tty option in run function is better

@itelmenko
Copy link

@antonmedv , sorry
Deployer 5 is very slow in first run.
It run "ssh multiplexing initialization" before each command.
But if I press Ctrl+C and rerun deploy, then it works quickly.
Why? Is it a bug?

@antonmedv
Copy link
Member

Looks like bug in openssh. Try create simple bash script with same commands and run it.

@itelmenko
Copy link

@antonmedv ,
Why after Ctrl+C and reruning Deployer, it does not write 'ssh multiplexing initialization' ?

@antonmedv
Copy link
Member

@itelmenko i don't know. Only way is to see what there are ssh doing (need to pass -vvvv to ssh call)

@itelmenko
Copy link

Deployer v5 log.
deployer.log.txt

First run was aborted because it is very slow.
After rerun deployment process was quick.
User's name and domain name have changed in log file.

@antonmedv
Copy link
Member

Try to update to new openssh.

@itelmenko
Copy link

Issue which I have looks like #1187

@whitewhidow
Copy link

not completely sure if related, but when i have jenkins run (sf3recipe) deployer, i am getting

TTY mode requires /dev/tty to be read/writable.

adding the git_tty option does not seem to help, any advice ?

@antonmedv
Copy link
Member

set git_tty to false
in jenkins no tty

@whitewhidow
Copy link

yep thx, found out just after posting, and thx for the FAST reply !! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants