The Connection.__init__() constructor sets self.client to an instance of
the paramiko SSHClient class, so you can alter it as needed after init.
Connections are not actually established until Connection.open() is called,
which happens automatically when using Connection.run or other functions
that
>From a quick search, seems MacOS doesn't have an entry for localhost in
/etc/hosts. Try adding one and see if that works. If not, maybe add some
for these hosts you're using as well.
Can I have multiple fabfile.py files for executing multiple tasks?
>
> For example :- fabfile1.py , fabfile2.py, fabfile3.py .. to execute
> multiple tasks on multiple servers.
>
> Please correct me. I look forward to hearing from you.
>
> Thanks in advance.
>
> Best Reg
ile. Please correct me. I look forward to
> hearing from you.
>
> Thanks in advance.
>
> Best Regards,
>
> On Fri, Apr 16, 2021 at 12:36 PM Kaushal Shriyan
> wrote:
>
>> Thanks Brandon for the email and it worked like a charm. Appreciate your
>> help !!!
>&
```
>>> connection = Connection(host="192.168.0.188", user="root", port=22,
>>> connect_kwargs={"password":"test@#!123"})
>>> result = connection.run('uname -a')
```
On Thu, Apr 15, 2021 at 1:20 PM Kaushal Shriyan
The connection object you're making is just a dictionary. Those keys should
be keyword arguments to the Connection constructor you imported.
On Thu, Apr 15, 2021, 09:21 Kaushal Shriyan
wrote:
>
> On Thu, Apr 15, 2021 at 6:05 PM Kaushal Shriyan
> wrote:
>
>> Hi,
>>
>> $fab -V
>> Fabric 2.6.0
>>
`pip install fabric==1.14` to install the last version of fabric 1.
If you're using Python 3 you need to either upgrade your fabfile to
fabric2 syntax or for now try to use the fabric3 side project.
On Fri, Sep 11, 2020 at 10:30 AM Nikunj Mistry wrote:
>
> Dear fabric team,
>
> I am fabric 1
; useful example to put into the docs (that is,calling an invoke task from a
> fabric task). It does not seem to be something very common, but I had a lot
> of trouble finding a solution without falling back to this mailing list.
>
> On Tue, Apr 2, 2019 at 5:35 PM Brandon Whaley wrot
or config key found for 'local'
>
> Valid keys: ['connect_kwargs', 'forward_agent', 'gateway', 'inline_ssh_env',
> 'load_ssh_configs', 'port', 'run', 'runners', 'ssh_config_path', 'sudo',
> 'tasks', 'timeouts', 'user']
>
> Valid real attributes: ['cd', 'clear', 'config',
Hi Mich,
The connection object (you're using ctx in your examples) has a .local
method that is just a pass-through to invoke.run. It's documented on
the connection object's page:
http://docs.fabfile.org/en/2.4/api/connection.html?highlight=local#fabric.connection.Connection.local
On Mon, Apr 1,
You might be able to use su's -c parameter to run each command
individually, so try something like this:
command_template = "su -c '{}'"
command = command_template.format("ls /root")
print("Response on {} is: {}".format(command, dss.run(command,
pty=False, watchers=[sudopass])))
Just be careful
There's a command line option that sets an environment variable for
keepalive:
http://docs.fabfile.org/en/1.13/usage/fab.html?highlight=keepalive#cmdoption--keepalive
On Thu, Jul 26, 2018 at 10:59 AM Rob Marshall
wrote:
> Hi,
>
> I have been having issues that a task I'm running as parallel
t callable or a valid task name
>
> Aborting.
>
> Fatal error: 'hostname' is not callable or a valid task name
>
> Aborting.
>
> Fatal error: 'uname' is not callable or a valid task name
>
> Aborting.
>
> Fatal error: 'hostname' is not callable or a valid task name
lts
>
> Which allows me to pass in arguments to the tasks. I did run into one
> odd thing: If I just tried to run run_parallel() as a function I got
> an error:
>
> Fatal error: '...' is not callable or a valid task name
>
> So what I ended up doing (not sure if there's a better way) was:
Hi Rob, I've done this as a hack in the past by adding data to the host
list and parsing it before execution to determine what to run. I've built
a simple example to give you an idea:
@task
def hostname():
return run('hostname')
@task
def uname():
return run('uname -a')
@task
def
I think you may be able to use su by setting up a watcher for su's password
prompt and using su -c "command" via run:
http://docs.pyinvoke.org/en/latest/concepts/watchers.html#autoresponding
responder = Responder(
pattern=r"Password: ",
response="thisismysecretpassword",
Another thought, perhaps your problem is keepalive?
http://docs.fabfile.org/en/1.14/usage/env.html#keepalive
On Thu, Jun 14, 2018 at 4:54 PM Brandon Whaley wrote:
> How are you setting the timeout? I would try this if you have not already:
>
> with settings(command_tim
How are you setting the timeout? I would try this if you have not already:
with settings(command_timeout=3600):
run("my long command")
On Thu, Jun 14, 2018 at 4:17 PM Rob Marshall
wrote:
> Hi,
>
> I'm running a remote command using Fabric 1.13.2 which keeps timing
> out after 10
fabric.api only exists in fabric 1.x, if you want to follow tutorials for
that older version, you should install Fabric==1.14.0
If you'd like to use fabric 2.x, the docs on the site are updated (with an
upgrade guide link at the bottom): http://fabfile.org/
On Sat, May 19, 2018 at 9:01 AM
ndle cases like host connection failures etc? I
> don't have control over returning that information from task function.
>
> Thanks
>
>
> On Thu 17 May, 2018, 20:56 Brandon Whaley, <redkr...@gmail.com> wrote:
>
>> You need to have your worker function catch any excep
You need to have your worker function catch any exceptions (
https://github.com/fabric/fabric/blob/1.14/fabric/exceptions.py) and
evaluate success/failure, then return a value useful to you in determining
if your task was successful. Returning "None" for failure modes is
something I've done
In the first example, you're trying to use a format method that is not
supported in python. In your second example, you're using the format
operator on the second string instead of the first in the put call. Here's
what you should do:
def myput():
myvar = env.host_string
I gave fexpect a look and it doesn't have any logic to handle instances
where two expectations have the same lookup key. You can see the relevant
code here:
https://github.com/ilogue/fexpect/blob/master/ilogue/fexpect/internals.py#L57
If I were to implement what you want to do, I would either
Hi Stephen,
I'd probably take advantage of the fact that host strings in fabric can
include the username using @ syntax: user@host
def deploy(release):
deployables = init_deployables(release)
# API kill first
hosts = set(
'{}+autobot@{}'.format(
Hi Jeff, it sounds like you may have an invalid host key, possibly in your
known hosts file? Can you try moving your known_hosts file out of place
temporarily and testing that you can reach out to a known good ssh server?
On Tue, Oct 31, 2017 at 12:17 PM Honey, Jeff
Looks like fabric keeps a dictionary of found tasks in
fabric.state.commands:
https://github.com/fabric/fabric/blob/1.13.1/fabric/state.py#L405
You could give this a try:
```
from fabric.state import commands
for task in commands.values():
if hasattr(task, 'return_value'):
del
I would use execute to call my task to run git pull, then have the task
return the output to the parent task and write it to a log file for viewing
in nano. For example:
from fabric.api import run, cd, execute, task, local
@task
def git_pull():
with cd('/home/myuser/mygitrepo'):
Fabric performs this caching of the ssh config file deliberately to improve
performance. The easiest way for you to break this functionality is to
delete the '_ssh_config' key from the env dictionary, since that key's
existence is what Fabric tests for before loading the config from disk
here:
able[env.host_string]
> run("command with {}".format(param))
>
> def launcher():
> param_table = {
> '192.168.1.100': 'param1',
> '192.168.1.200': 'param2',
> }
> execute(task, param_table, hosts=list(param_table))
>
>
>
Glad to help!
On Fri, Dec 9, 2016, 14:04 Erikton Konomi <konoe...@gmail.com> wrote:
> Thanks Brandon! This is very helpful.
>
> On Thu, Dec 8, 2016 at 3:46 PM, Brandon Whaley <redkr...@gmail.com> wrote:
>
> That functionality is not built in to fabric. Either have
That functionality is not built in to fabric. Either have your task query
for what param it should use based on the value of env.host_string or abuse
host strings to pass the arguments like so:
@parallel
def task():
#naturally requires that param not contain '_', use another non-valid
host
I would use a combination of
http://docs.fabfile.org/en/1.12/usage/env.html#abort-on-prompts and
http://docs.fabfile.org/en/1.12/usage/env.html#abort-exception to have
Fabric throw a custom exception when it has to prompt, which I would
subsequently catch and handle myself based on context.
On
have this behaviour?
>
> Many Thanks,
>
> Regards,
>
>
> Alexandre
>
>
> - Original Message -
> From: "Brandon Whaley" <redkr...@gmail.com>
> To: "a hocquel" <a.hocq...@free.fr>, fab-user@nongnu.org
> Sent: Thursday, 17
It sounds like that user is not allowed to run shells. Try setting
env.shell to an empty string. You'll lose the ability to use any shell
specific commands via run but what you're running in your example should be
fine.
On Sat, Oct 22, 2016 at 1:29 PM santosh kumar wrote:
Hi Bogdan, you have to have fabric on the remote system to import fabric
from a python file. If you don't want to do this globally on the system,
just set up a virtualenv as your user. There are plenty of tutorials for
using virtualenv online.
On Sat, Sep 10, 2016 at 2:13 PM Carlos García <
There is no facility in fabric to load files from the gateway machine for
use as keys.
On Sun, Jul 24, 2016 at 2:08 PM Roshan Shetty
wrote:
> Hi,
>
> I have asked this question on stack overflow but i haven't received any
> response.
>
> My scenario:
>
> Local host ->
There are two approaches here. The first is to open a file and write the
result of the 'w' command from within checkconn, the other is to redirect
from the shell.
$ fab checkconn > checkconn_result.log
OR
def checkconn():
result = run('w')
with open('checkconn_result.log', 'w') as f:
I've found that it's best not to set env.hosts in code but instead to
define roles based on your config file and use the fab tool to specify a
role. Here's an example:
my_roles.json
{
"web": [ "u...@web1.example.com", "u...@web2.example.com" ],
"db": [ "u...@db1.example.com",
That really sounds like a job for ssh keys to me, just setting up key
authentication will go a long way toward uncomplicating your ssh usage. I
also wouldn't use the @hosts decorator if you're pulling in your host list
dynamically. I always recommend using the execute() function if you intend
to
Try using -w on the command like (or with settings(warn_only=True):).
Sounds like the command you're running isn't returning 0.
On Wed, Jan 6, 2016 at 2:04 PM Bader, Robert (Bob Bader) <
bob.ba...@cchmc.org> wrote:
> Hi,
>
>
> First off I am new to fab, another admin showed me it’s power and I
You're executing mycallable in your env.roledefs definition. Remove the
"()" from the end and it should work as advertised.
On Mon, Jan 4, 2016 at 10:01 PM James Litton wrote:
> I’m having an issue with using callables for env.roledefs. The
> documentation suggests that
The docs for fabric are here: http://docs.fabfile.org/en/1.10/
I don't think that fabric8.io is in any way affiliated.
I don't know what you mean by "Doesn't work", can you elaborate?
On Wed, Nov 25, 2015 at 8:38 AM Tameem Ahmed wrote:
> Hi,
>
> I have this simple fab
lcd is intended to modify the local() call (and maybe get, put, et al? I
haven't tested). It does not actually change the cwd afaik.
>>> from fabric.api import local, lcd
>>> print fabric.api.local('pwd', capture=True)
[localhost] local: pwd
/home/redkrieg/projects/fabric
>>> with
reate a queue
> in the master task and make the subtask send messages to it?
>
>
>
> Original message
> From: Brandon Whaley <redkr...@gmail.com>
> Date: 2015-09-10 5:10 PM (GMT-05:00)
> To: Felix Almeida <felix.alme...@rci.rogers.com>, fab-user@no
Parallel uses multiprocessing, so you're opening output.csv in write mode
once per host. You'll need to have a master task consolidate the return
values of your parallel subtask (use execute) and write the csv once
everything is done. Remember that execute returns a dictionary whose keys
are the
Hi Len, the output seems to indicate that the command was read but not
acted on. Do you need to authenticate in some non-ssh way in order to
run that command? If not, I might experiment with putting a newline or an
EOF character in env.shell to see if that gets you to the OCM# prompt.
On Tue,
Hi Michael, it sounds like your dzdo config limits what commands can
be run (correct me if I'm wrong) and that invoking /bin/bash directly
is not allowed. Have you tried setting env.use_shell=False?
http://docs.fabfile.org/en/1.10/usage/env.html?highlight=use_shell#use-shell
On Wed, Apr 1, 2015
Hi Matthias,
How are you loading the contents of __init__.py? I don't see any
module imports in your test.py file. I would generally put what you
have there directly in the fabfile itself, right after the fabric.api
import.
On Tue, Aug 19, 2014 at 11:21 AM, Matthias Witte
Hi Justin,
In your example code, you're setting a local variable named prompts. Try
setting env.prompts instead.
On Thu, Jun 26, 2014 at 11:30 AM, Justin Polidora jjpolid...@gmail.com
wrote:
Hi,
I am using Fabric 1.9 and am trying to control an interactive prompt from
a bash script.
Hey Jon,
Fabric doesn't actually make multiple connections, it reuses them:
http://docs.fabfile.org/en/1.8/usage/execution.html?highlight=cache#connections
The live connections are stored in fabric.state.connections for the life of
your program run (I believe, feel free to correct me if I'm
It's documented, but since it's not fabric specific, you need to look at
the docs for the tool that put it there. :)
https://pythonhosted.org/setuptools/easy_install.html#use-the-user-option
On Dec 8, 2013 11:50 AM, Angel angel.delano1...@gmail.com wrote:
Hi, actually, as I installed it in my
. Can execute be
used within fabric tasks to change the set of hosts and run new actions on
the new hosts?
thanks,
-nathan
On Fri, Oct 25, 2013 at 9:51 PM, Brandon Whaley redkr...@gmail.comwrote:
I prefer using execute:
http://docs.fabfile.org/en/1.8/api/core/tasks.html?highlight=execute
Hi Ian,
Is there any reason you can't whip up a fab function to use execute() and
the parallel decorator to perform this task? If you want it to be
re-usable without editing code, have it load a config file (json or
otherwise) that describes the options to do per container. Another
strategy
Neglected to reply to all.
-- Forwarded message --
From: Brandon Whaley redkr...@gmail.com
Date: Feb 18, 2013 1:00 AM
Subject: Re: [Fab-user] Fab fails to run for certain users
To: Edgar DeLoa ede...@gmail.com
Cc:
Hey Edgar, does the other user have a valid shell program like bash
Forgot to reply-all, sorry.
-- Forwarded message --
From: Brandon Whaley redkr...@gmail.com
Date: Dec 13, 2012 11:33 AM
Subject: Re: [Fab-user] little example needed
To: Oswald, Thomas th.osw...@telekom.de
Cc:
Hi Thomas,
In my experience, many of the SSH implementations
Hello Jacqueline,
The return code of 127 you're getting means that the command was not
found. I suspect the path to this command is being included in your
path by the shell environment, so when you use shell=False you're
excluding that from your path. Try using the full path to that
executable
PM, Brandon Whaley redkr...@gmail.com wrote:
Hello Jacqueline,
The return code of 127 you're getting means that the command was not
found. I suspect the path to this command is being included in your
path by the shell environment, so when you use shell=False you're
excluding that from your
57 matches
Mail list logo