Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:46:21+00:00 2026-06-17T22:46:21+00:00

I want to run different command on the different pc group. my fabric file

  • 0

I want to run different command on the different pc group.
my fabric file like following:

env.hosts = ['125.221.225.31','125.221.225.36','125.221.225.33','125.221.225.34','125.221.225.35']
env.roledefs = {
    'master':['125.221.225.31'],
    'slave':['125.221.225.33','125.221.225.34','125.221.225.35','125.221.225.36']}

@roles('master')
def get_last_hosts():
    with cd('/etc'):
        get('hosts','/tmp/hosts')

@roles('slave')
def upload_hosts():
    with lcd('/tmp'):
        put('hosts','/etc/hosts',use_sudo=True)

def update_hosts():
    get_last_hosts()
    upload_hosts()

I can run:

fab get_last_hosts,

and then run:

fab upload_hosts 

I want to merge these steps to one step, so to say:

update_hosts

but that won’t work, it will run update_hosts on every pc in the env.hosts, that’s not what I desire.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:46:22+00:00Added an answer on June 17, 2026 at 10:46 pm

    You can get around this by using the execute command. In something like this:

    def update_hosts():
        execute(get_last_hosts)
        execute(upload_hosts)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a program with different configuration file, the program write with
I want to run the same JUnit tests for different interface implementations. I found
I want run all script from the directory . Like , The directory contains
I want to run a CSharp process from my java server under a different
I have this MS-DOS program that I want to run on a different computer
I have a program called MyProgram.java . I want to run it from different
As the topic says, I want to be able to run a specific command
I have three different crawler scripts that I want to run in parallel and
I want to run a jar file with a .bat (the jar file doesn't
This problem makes me confused I just want to run 1 command on 18

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.