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 7845645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:18:20+00:00 2026-06-02T17:18:20+00:00

I just started using Fabric to better control the specific settings for test and

  • 0

I just started using Fabric to better control the specific settings for test and deployment environments, and I’m trying to get an idea of the best approach to swapping configurations.

Let’s say I have a module in my application that defines a simple database connection and some constants for authentication by default:

host = 'db.host.com'
user = 'someuser'
passw = 'somepass'
db = 'somedb'

class DB():
  def __init__(self,host=host,user=user,passw=passw,db=db,cursor='DictCursor'):
    #make a database connection here and all that jazz

Before I found fabric, I would use the getfqdn() function from the socket library to check the domain name of the host the system was being pushed to and then conditionalize the authentication credentials.

if getfqdn() == 'test.somedomain.com':
  host = 'db.host.com'
  user = 'someuser'
  passw = 'somepass'
  db = 'somedb'
elif getfqdn() == 'test.someotherdomain.com':
  host = 'db.other.com'
  user = 'otherguy'
  passw = 'otherpass'
  db = 'somedb'

This, for obvious reasons, is really not that great. What I would like to know is what’s the smartest way of adapting something like this in Fabric, so that when the project gets pushed to a certain test/deployment server, these values are changed at post-push.

I can think of a few approaches just from looking through the docs. Should I have a file that just defines the constants that Fabric could output to using the shell commands based off what the deployment was, and then the file defining the database handler could import them? Does it makes sense to run open and write from within the fabfile like this? I assumed I’d also have to .gitignore these kinds of files so they don’t get committed into the repo and just rely on Fabric to deploy them.

I plan on adapting whatever approach is the best suggested to all the configuration settings that I currently either swap using getfqdn or adjust manually. Thanks!

  • 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-02T17:18:23+00:00Added an answer on June 2, 2026 at 5:18 pm

    You can do all of that off of the env.host and then use something like the contrib template function to render the conf file and push it up. But templates are best in these instances (see: puppet and other config managers as well)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started using log4net and trying to get my head around the config and
I just started using Datamapper. I am trying to update an object. I get
I just started using the MVCContrib grid in a test project. I'm having a
I just started using IntelliJ-IDEA, and I don't know if the problem resides with
I just started using Matplotlib and am trying to change the color of the
I just started using resharper and I am trying to learn all the hotkeys
I just started using SASS and I am trying to figure out how to
I just started using git with github. I followed their instructions and ran into
I just started using django for development. At the moment, I have the following
I just started using ELMAH and am a fan. My team supports a large

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.