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

Add a skip_on_prompts #521

Closed
reeesga opened this issue Jan 2, 2012 · 2 comments
Closed

Add a skip_on_prompts #521

reeesga opened this issue Jan 2, 2012 · 2 comments

Comments

@reeesga
Copy link

reeesga commented Jan 2, 2012

If I cronjob a fabric task towards multiple hosts (-H ) and one of them has e.g. changed password, the session hangs, asking for a password. If I set the "abort_on_prompts", the session exits instead, and the rest of nodes in the role are never tasked.

So I'm needing something like a "skip_on_prompts" for my fully automated fabfile.

Can I make up this behaviour somehow? I tried setting env.abort_on_prompts=True, then wrapping into a warn_only=True, but the abort proceeds anyway.

Or, put in another way, warn_only=True should take precedence over abort_on_prompts=True.

@reeesga
Copy link
Author

reeesga commented Jan 2, 2012

Ok, so I just found a workaround for this by catching the abort exception;

 with settings(user=host_user, password=host_password, abort_on_prompts=True):
     # Try to SSH into the node and run a simple command
     try:
         run('pwd')
     except SystemExit, e:
         print 'SSH login into %s failed!' % env.host
     else:
         print 'SSH login into %s was ok' % env.host

@KarnG
Copy link

KarnG commented Aug 13, 2016

Hello Experts, I am newbie into the fabric, i have the same problem "password prompt" if it has wrong password, How i can customise by below fab file..

import sys
from fabric.api import *
env.skip_bad_hosts=True
env.command_timeout=160
env.user = 'user1'
env.shell = "/bin/sh -c"
env.warn_only = True
env.abort_on_prompts = True
env.password = 'pass123'
def readH():
env.hosts = [line.strip() for line in sys.stdin.readlines()]

def cpam():
with settings(warn_only=True):
output=sudo("/grid/it/bin/cyberAddHost.sh",shell=False)

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

2 participants