Re: Two factor authentication?

2022-11-10 Thread Brandon Whaley
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

Re: socket.gaierror: [Errno 8] nodename nor servname provided, or not known

2022-03-31 Thread Brandon Whaley
>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.

Re: ModuleNotFoundError: No module named 'fabric.api'

2021-04-16 Thread Brandon Whaley
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

Re: ModuleNotFoundError: No module named 'fabric.api'

2021-04-16 Thread Brandon Whaley
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 !!! >&

Re: ModuleNotFoundError: No module named 'fabric.api'

2021-04-15 Thread Brandon Whaley
``` >>> 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

Re: ModuleNotFoundError: No module named 'fabric.api'

2021-04-15 Thread Brandon Whaley
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 >>

Re: Fabric ssh not working as before

2020-09-11 Thread Brandon Whaley
`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

Re: [Fab-user] How do I combine "local" with "remote" tasks in fabric 2?

2019-04-02 Thread Brandon Whaley
; 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

Re: [Fab-user] How do I combine "local" with "remote" tasks in fabric 2?

2019-04-01 Thread Brandon Whaley
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',

Re: [Fab-user] How do I combine "local" with "remote" tasks in fabric 2?

2019-04-01 Thread Brandon Whaley
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,

Re: [Fab-user] Fabric 2.4.0 problem - Run method is not being finished

2018-12-28 Thread Brandon Whaley
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

Re: [Fab-user] keepalive for parallel tasks

2018-07-26 Thread Brandon Whaley
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

Re: [Fab-user] Run multiple commands on single host in parallel

2018-06-19 Thread Brandon Whaley
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

Re: [Fab-user] Run multiple commands on single host in parallel

2018-06-19 Thread Brandon Whaley
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:

Re: [Fab-user] Run multiple commands on single host in parallel

2018-06-18 Thread Brandon Whaley
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

Re: [Fab-user] Run as root without sudo and root ssh disabled

2018-06-15 Thread Brandon Whaley
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",

Re: [Fab-user] Command timeout after 10 minutes

2018-06-14 Thread Brandon Whaley
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

Re: [Fab-user] Command timeout after 10 minutes

2018-06-14 Thread Brandon Whaley
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

Re: [Fab-user] ImportError: No module named api while running fabric 2.0.1 python code.

2018-05-19 Thread Brandon Whaley
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

Re: [Fab-user] How to gracefully/elegantly collect data about failed hosts when using fabric.api.execute? (v1)

2018-05-17 Thread Brandon Whaley
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

Re: [Fab-user] How to gracefully/elegantly collect data about failed hosts when using fabric.api.execute? (v1)

2018-05-17 Thread Brandon Whaley
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

Re: [Fab-user] variable substitution

2018-04-17 Thread Brandon Whaley
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

Re: [Fab-user] Regarding fexpect in fabric python

2017-11-23 Thread Brandon Whaley
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

Re: [Fab-user] running parallel executions with different env.user

2017-11-09 Thread Brandon Whaley
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(

Re: [Fab-user] new install troubles

2017-10-31 Thread Brandon Whaley
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

Re: [Fab-user] Clearing runs_once?

2017-03-10 Thread Brandon Whaley
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

Re: [Fab-user] skipping editor while executing the remote command

2017-02-23 Thread Brandon Whaley
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'):

Re: [Fab-user] Fabric 1.13.1 seems not reload the ssh_config file

2017-01-25 Thread Brandon Whaley
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:

Re: [Fab-user] Parallel Tasks With Different Parameters

2016-12-09 Thread Brandon Whaley
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)) > > >

Re: [Fab-user] Parallel Tasks With Different Parameters

2016-12-09 Thread Brandon Whaley
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

Re: [Fab-user] Parallel Tasks With Different Parameters

2016-12-08 Thread Brandon Whaley
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

Re: [Fab-user] when password is wrong

2016-12-05 Thread Brandon Whaley
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

Re: [Fab-user] HP switches and run() received nonzero return code -1 while executing

2016-11-18 Thread Brandon Whaley
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

Re: [Fab-user] ssh -i && env.key_filename

2016-10-22 Thread Brandon Whaley
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:

Re: [Fab-user] Fabric question

2016-09-10 Thread Brandon Whaley
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 <

Re: [Fab-user] How to specify pem file path when using gateway in Fabric

2016-07-25 Thread Brandon Whaley
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 ->

Re: [Fab-user] fabric std output to file

2016-07-18 Thread Brandon Whaley
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:

Re: [Fab-user] (no subject)

2016-07-04 Thread Brandon Whaley
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",

Re: [Fab-user] Multiple users and passwords

2016-04-15 Thread Brandon Whaley
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

Re: [Fab-user] issue with fab command on remote system

2016-01-06 Thread Brandon Whaley
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

Re: [Fab-user] issue with env.roledefs callable

2016-01-04 Thread Brandon Whaley
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

Re: [Fab-user] How do I execute fabric script from a Java Program

2015-11-25 Thread Brandon Whaley
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

Re: [Fab-user] lcd seems broken

2015-10-01 Thread Brandon Whaley
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

Re: [Fab-user] Can't save output to a CSV file if running task in parallel

2015-09-10 Thread Brandon Whaley
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

Re: [Fab-user] Can't save output to a CSV file if running task in parallel

2015-09-10 Thread Brandon Whaley
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

Re: [Fab-user] not fabbing to *nix

2015-06-02 Thread Brandon Whaley
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,

Re: [Fab-user] using fabric with dzdo

2015-04-01 Thread Brandon Whaley
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

Re: [Fab-user] Using execute appears to break ssh_config configuration

2014-08-19 Thread Brandon Whaley
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

Re: [Fab-user] How to properly use interactive prompts

2014-06-26 Thread Brandon Whaley
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.

Re: [Fab-user] fabric as library, access pool of connections indexed by host

2014-03-21 Thread Brandon Whaley
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

Re: [Fab-user] no fab command line tool

2013-12-08 Thread Brandon Whaley
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

Re: [Fab-user] Deploying to multiple sets of hosts

2013-10-26 Thread Brandon Whaley
. 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

Re: [Fab-user] Parallel operations for container creation

2013-05-14 Thread Brandon Whaley
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

[Fab-user] Fwd: Re: Fab fails to run for certain users

2013-02-17 Thread Brandon Whaley
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

Re: [Fab-user] little example needed

2012-12-13 Thread Brandon Whaley
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

Re: [Fab-user] Sudo fails on Solaris hosts

2012-01-18 Thread Brandon Whaley
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

Re: [Fab-user] Sudo fails on Solaris hosts

2012-01-18 Thread Brandon Whaley
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