[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fab-user] How is config file merged into environment?
From: |
Steve Steiner (listsin) |
Subject: |
[Fab-user] How is config file merged into environment? |
Date: |
Fri, 26 Jun 2009 22:36:50 -0400 |
I'm wanting to move my hosts off into config files so that I can apply
the same sets of commands in my fabfile to different hosts by
switching config files instead of editing fabric.py.
I have a simple test fabfile.py:
# fabfile.py
# ------------
from fabric.api import env, run, sudo
from fabric.context_managers import cd
from fabric.operations import put
from os import path
env.user = "root"
env.hosts = ["xxx.yyy.zzz.kkk"]
# NOTE: LIB
def ls():
"""ls whatever directory you're in"""
return sudo("ls -Gla")
I want to just move the env.host declaration out to the config file
like so:
my.cfg
----------------
hosts = ["xxx.yyy.zzz.kkk"]
So, I comment out the env.hosts line in fabfile.py, and call fabric
like so:
fab --config=my.cfg ls
After the annoying deprecation warnings from Parimiko I get:
No hosts found. Please specify (single) host string for connection:
I've tried rearranging the assignment in my.cfg in all the obvious
ways but I either I get a message about not being able to open "'["1"
or some other fragment, or am just prompted for a host to connect to.
I looked through the code and it seems to just parse the config file
with a nested list comprehension, dense but not particularly obtuse,
then send the resulting dict back to the env dictionary for updating.
I'm running of the master just pulled from github a few minutes ago.
What idiotically simple thing am I missing?
Clues anyone?
Thanks,
S
- [Fab-user] How is config file merged into environment?,
Steve Steiner (listsin) <=