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

  • SEARCH
  • Home
  • 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 8600851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:42:32+00:00 2026-06-12T01:42:32+00:00

In my fabric scripts I have the following problem. I have a main task

  • 0

In my fabric scripts I have the following problem. I have a main task called autodeploy. Within this task I have some tasks that I only want to run once, locally. all remote tasks should run on each of the hosts of the host list.

env.roledefs ={
  'testing': ['t-server-01', 't-server-02']  
  'staging': ['s-server-01', 's-server-02']  
  'live': ['l-server-01', 'l-server-02']  
}

def localtask1():
  # download artifact

def localtask2(): 
  # cleanup locally

def remotetask():
  # deploy artifact to all hosts

def autodeploy():
  localtask1() # run this task only once, locally  

  remotetask() # run this task on all hosts

  localtask2() # run this task only once

The call is the following. I want to pass the role as an attribute.

fab -R test autodeploy
  • 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-12T01:42:33+00:00Added an answer on June 12, 2026 at 1:42 am

    Use the execute function inside the wrapper function autodeploy, and specify a host list for the remote task.

    For the other two you can call them with execute, like for the remote task, or directly. Use the local function inside them and you’ll be fine, and not need to have ssh on localhost.

    Docs are here for how best ot use the new execute function.

    EDIT

    Since you mention a different use case in the comments I’ll mock up how you’d do that, from bits in the documentation given already, adding the param passing section

    code:

    #copy above
    
    #redefine this one
    def autodeploy(role_from_arg):
        localtask1()
        execute(remotetask, role=role_from_arg)
        localtask2()
    
    #calls like fab autodeploy:testing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Fabric task that needs to access the settings of my Django
Assuming that I have the following directory structure for a Python project: config/ scripts/
I have a fabric task set up like this: @task def cli(): command =
I need to use Fabric to do some operations in a website that use
I'd like my Fabric tasks to have hyphens (-) instead of underscores (_). For
I have a system that i use to run a fabric script that executes
Here is my problem: I have got a Python build script that executes several
I have a django app and I wrote a fabric script that installs my
I have a fabric script that attempts to run the tests for an application
I have a simple fabric.canvas element which has a background and I have set

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.