Questions tagged [python-fabric-2]
16 questions
5
votes
1 answer
Fabric 2: configuring sudo passwords for various hosts
I am looking for a way to configure passwords for "sudoing" in the various hosts targeted by a fabfile.py. I accept "clear" passwords" in a ~/.fabric.py|yaml|json but not in the fabfile.py.
Unless I didn't read correctly, the fabric documentation…

glenfant
- 1,298
- 8
- 9
5
votes
3 answers
Fabrics 2.x ssh connection using identity fails to work
Trying to connect to the host described in ssh config using fabrics 2 and identity file.
con = Connection('my_host')
@task
def tt(c):
con.run('uname -a')
~/.ssh/config :
Host my_host
HostName 123.144.76.84
User ubuntu
IdentityFile…

Serafim Suhenky
- 2,140
- 1
- 15
- 18
2
votes
1 answer
OSError: [WinError 87] The parameter is incorrect
Trying to run python fabric 2 in windows 10
from fabric import task,SerialGroup,Connection
import os
USERNAME = os.getenv('USERNAME')
my_hosts = ["hostname"]
c = Connection(host="rg@host.com",connect_kwargs={"password":"abcd"})
@task
def test(c):
…

ramg
- 161
- 2
- 14
2
votes
1 answer
@task(hosts=[...]) yields Context but -H yields Connection?
Python 3.8.2, Fabric 2.5.0, Paramiko 2.7.2, Invoke 1.4.1
Hello,
I have a fabfile which needs to handle hosts passed at the command-line (using -H) and hosts defined in the fabfile if -H was not passed. Here's an example of the issue I'm…

monokal
- 71
- 6
2
votes
0 answers
Fabric 2 global settings for mutiple @tasks in fabfile.py
I'm using fabric 2.5, my fabfile looks like this:
# -*- coding: utf-8 -*-
from fabric import Connection
from fabric import task
@task
def sudowhoami(context):
context.config.sudo['password'] = context.connect_kwargs.password
…

AAS
- 111
- 2
- 6
2
votes
0 answers
How to use threading and sudo in fabric 2?
My question is the same as this one, but I'm not thrilled with the only answer. fabric 2.3 parallel execution of sudo commands
Hoping there are other opinions out there?
I'm trying to migrate my Python 2/Fabric 1 code to Python 3/Fabric 2. The code…

Bee
- 195
- 1
- 3
- 12
1
vote
0 answers
Fabric2 throws `paramiko.ssh_exception.AuthenticationException` during nested SSH to localhost (port 2022) on an AWS EC2 instance
Here is what I am trying to achieve:
SSH into an EC2 instance Node1.
Public IP is available for Node1.
I am using a .pem file to create Connection with Node1.
From Node1 ssh into localhost on port 2022: ssh admin@localhost -p 2022
Now execute a…

kusamit
- 19
- 3
1
vote
1 answer
Got "401 Client Error: Unauthorized" when execute st2 command with fabric 2
in fabric 1.14.0, below codes works well
from fabric.api import run, settings, hide
theCmd = 'st2 run core.http url="http://httpbin.org/get"'
user=''
ss_host=''
ss_bast=''
with settings(user=user,…

Phoenix
- 95
- 3
- 10
1
vote
0 answers
Fabric2 tasks and dependencies
How can I define dependencies between tasks correctly using Fabric?
Given the following fabfile.py:
from fabric.tasks import task
@task
def clean(c):
print(type(c))
@task(pre=[clean])
def deploy(c):
print(type(c))
Running this…

dubbaluga
- 2,223
- 5
- 29
- 38
1
vote
1 answer
How to create fabric2 tasks decorators?
Let's start by considering some unrefactored working piece of code that uses fabric2:
import traceback import inspect
from fabric2.tasks import task
from fabric2 import Config, Connection
def get_function_name():
return…

BPL
- 9,632
- 9
- 59
- 117
1
vote
1 answer
Fabric 2.5, how to skip a host if it is unavailable?
I use Fabric 2.5 and have not many servers (10-20), at any time, everyone can become inaccessible, this is normal behavior. How I can check the connection or skip a bad host?
In Fabric 1.4 we can use --skip-bad-hosts (and env.skip_bad_hosts) to…

Arslanbekov Denis
- 1,674
- 12
- 26
0
votes
0 answers
How to override Invoke configuration project-wide for Fabric?
I'm currently specifying a connection override per constructor call: fabric2.Connection(…, config=invoke.Config(overrides={"shell": "bash"})). How would I translate this to a configuration file, so that I don't have to configure it per call?
Fabric…

l0b0
- 55,365
- 30
- 138
- 223
0
votes
1 answer
How to specify local shell for Fabric2/Paramiko/Invoke?
When trying to create a fabric2.Connection, Paramiko tries to invoke a local /bin/bash command:
$ fab2 db-shell
Traceback (most recent call last):
File "/nix/store/m2iyj18cifr4a1rvpfgphg7kfgsf2pj2-python3.9-fabric2-2.7.1/bin/.fab2-wrapped", line…

l0b0
- 55,365
- 30
- 138
- 223
0
votes
1 answer
Got error from message.py - paramiko "object of type 'bool' has no len()" when executing fabric.Connection.run()
I use fabric 2.6.0, paramiko 2.9.2 and invoke 1.4.0
Is this bug or something incompatible I got an error like this.
File "/usr/local/lib/python3.7/dist-packages/paramiko/message.py",
line 274, in add_string
self.add_int(len(s)) TypeError: object of…

dhentris
- 198
- 1
- 2
- 10
0
votes
1 answer
Fabric 2 using global settings
In Fabric1 there was the ability to put a bunch of settings in the fabfile.py and import the actually tasks from another package. This is wanted as I'm using these tasks for a multiple projects.
Like so:
from fabric.api import env
env.django_dir…

S.D.
- 2,486
- 1
- 16
- 23