面料环境不符合预期 [英] Fabric env.roledefs not acting as expected

查看:89
本文介绍了面料环境不符合预期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Fabric网站上,给出了以下示例:

On the fabric website, this example is given:

from fabric.api import env

env.roledefs = {
    'web': {
        'hosts': ['www1', 'www2', 'www3'],
        'foo': 'bar'
    },
    'dns': {
        'hosts': ['ns1', 'ns2'],
        'foo': 'baz'
    }
}

据我所知,在主机"www1","www2","www3"上执行时,此设置应为env dict键"foo"赋予值"bar".尽管Fabric确实可以正确确定主机,但我无法获得此行为. fabfile示例:

As far as I can tell from the documentation, this setup should give the env dict key 'foo' the value 'bar' when executing on hosts 'www1', 'www2', 'www3'. I cannot get this behavior, though fabric does correctly determine hosts. An example fabfile:

env.foo = 'WRONG'
@task()
def set_role():
    env.roles.append('web')

@task()
def print_foo():
    print env.foo

示例命令:

fab set_role print_foo

意外的输出:

[www1] Executing task 'print_foo'
WRONG
[www2] Executing task 'print_foo'
WRONG
[www3] Executing task 'print_foo'
WRONG

Done.

我误解了这个目的吗?如何使一台服务器看到的密钥值与另一台服务器看到的值不同而又没有太多麻烦呢?

Am I misunderstanding the purpose of this? How can I make it so that one server sees a different value for a key then another without too much trouble?

我正在使用结构1.10.0

I am using fabric 1.10.0

推荐答案

我也对此感到困惑.事实证明,可以在Fabric 1.11中访问它们: https://github.com/fabric/fabric/issues/1276

I was confused by this too. It turns out that it is going to be possible to access these in Fabric 1.11: https://github.com/fabric/fabric/issues/1276

这篇关于面料环境不符合预期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆