Discussion:
[Fab-user] skipping editor while executing the remote command
Roshan Shetty
2017-02-23 21:02:59 UTC
Permalink
Hi guys,

We are manually doing *git pull *on 20+ servers.

once the git pull gets completed, it will open *some log message in nano
editor.*

I'm trying to automate the above process.

But the problem is with log messages opening in editor.

Is there any way to skip that part using fabric ?



Regards,
Roshan


*The only way to do great work is to love what you do. If you haven’t found
it yet, keep looking. Don’t settle. As with all matters of the heart,
you’ll know when you find it.” - Steve Jobs*
Brandon Whaley
2017-02-23 21:21:27 UTC
Permalink
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'):
return run('git pull')

@task
def bulk_pull():
results = execute(git_pull, hosts=['host1', 'host2'])
with open('gitpull.log', 'w') as f:
for host, output in results.iteritems():
f.write("%s\n====\n%s\n\n" % (host, output))
local('nano gitpull.log')



Note that you are no longer able to specify hosts via command line with
this method, since bulk_pull should only target one host. Run via "fab
bulk_pull"
Post by Roshan Shetty
Hi guys,
We are manually doing *git pull *on 20+ servers.
once the git pull gets completed, it will open *some log message in nano
editor.*
I'm trying to automate the above process.
But the problem is with log messages opening in editor.
Is there any way to skip that part using fabric ?
Regards,
Roshan
*The only way to do great work is to love what you do. If you haven’t
found it yet, keep looking. Don’t settle. As with all matters of the heart,
you’ll know when you find it.” - Steve Jobs*
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Loading...