Posts

Showing posts with the label fabric

Python Fabric - No hosts found. Please specify (single) host string for connection:

Python Fabric - No hosts found. Please specify (single) host string for connection: How do I get No hosts found. Please specify (single) host string for connection: ? How to a resolve with fabric? def bootstrap(): host = 'ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com' env.hosts = [host] env.user = "ubuntu" env.key_filename = "/home/ubuntu/omg.pem" > command run >> fab bootstrap > No hosts found. Please specify (single) host string for connection: 3 Answers 3 Instead of setting hosts inside your task, do it before it gets called with a decorator: from fabric.api import hosts, env @hosts(['ec2-54-xxx.xxx.xxx.compute-1.amazonaws.com']) def bootstrap(): env.user = "ubuntu" env.key_filename = "/home/ubuntu/omg.pem" For more information on this, check out Defining host lists - there are a lot of different ways to do i...

Sudo in Fabric2

Sudo in Fabric2 I would like to reproduce the behavior of my old Fabric1 script running sudo('useradd -m -u --groups mygroup myuser') In that case the remote machine (an Ubuntu AWS instance) would prompt me for my sudo password and I was able to type it in. Even the repeated prompt after a wrong input would work. After that Fabric1 would hold on to that password by keeping the connection open. In my new Fabric 2.x script I am using within a @task c.sudo('useradd -m -u --groups mygroup myuser') I am still getting a user prompt but it does not wait for my response, I am not able to type the password, and it fails as expected with invoke.exceptions.AuthFailure: The password submitted to prompt '[sudo] password: ' was rejected Using the --prompt-for-sudo-password argument has the same (or no effect). I also tried run('sudo useradd -m -u --groups mygroup myuser') and received sudo: no tty present and no askpass program specified I would preferable not set the...