Skip to content

Allow fabricrc to be fabfile-esque Python module? #122

@bitprophet

Description

@bitprophet

Description

EDIT: updated subject to reflect another couple of users on the ML wanting basically the same thing -- ability to have more powerful user-specific settings and tasks -- basically an additional fabfile.

I think the best forward-looking approach to this is to simply allow a chain of fabfiles each executed and loaded in turn, so that the last one loaded takes precedence (i.e. overwrites env vars or task names.) In such a situation, a user "fabfile" would not be able to override a project-specific fabfile but would otherwise be able to contribute tasks and update env vars.

One issue with this is that the current "just call Python code" approach for composing subtasks won't work here as the fabfiles won't be aware of each other unless explicitly imported (in which case doing this is kind of silly anyways) so it would require the "call task X" mechanisms discussed in #21.

And even so it still feels odd because there's a disconnect -- explicitly referencing anything from an earlier fabfile in a later one would cause it to break anytime the earlier fabfile isn't there, and one runs into the Rubyesque problems of "why is this name being referenced, where is it coming from?" when attempting to debug. (This problem already exists for the .fabricrc, of course, when trying to debug env var values.)

Needs more thought.

Original ticket description follows:


Right now, if I try putting something in the fabricrc like:

hosts = 192.168.0.100

I get an exception on line 280 of main.py:

Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/fabric/main.py", line 408, in main
command, cli_hosts, cli_roles)
File "/usr/lib/python2.6/site-packages/fabric/main.py", line 302, in get_hosts
return _merge(state.env['hosts'], state.env['roles'])
File "/usr/lib/python2.6/site-packages/fabric/main.py", line 280, in _merge
return list(set(hosts + role_hosts))

It seems to me like this is because the settings are read in from fabricrc as a string.

I've attached a patch to try and solve the issue. I didn't use git or anything...I just copied main.py to main.py.original before modifying it.

Let me know if you have any questions or if I can do anything else.


Originally submitted by Aaron B. Russell (arussell) on 2009-12-15 at 07:55pm EST

Attachments

Relations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions