Why don't my fabric control parameters work?

63 Views Asked by At

Here is my fabric function:

def replace_config(vim_sig, bash_sig):
    """ replace remote server config with local config
    """
    default_path = change_path('config', default_path='~/')

    if vim_sig:
        local("scp %s.vimrc admin@%s:~/vimrc" % (default_path, env.host))
        sudo("cp /home/admin/vimrc /home/admin/.vimrc")
        sudo("cp  /home/admin/vimrc /root/.vimrc")
        sudo("rm /home/admin/vimrc")

    if bash_sig:
        local("scp %s.bashrc admin@%s:~/bashrc" % (default_path, env.host))
        sudo("cp /home/admin/bashrc /home/admin/.bashrc")
        sudo("cp  /home/admin/bashrc /root/.bashrc")
        sudo("rm /home/admin/bashrc")

# Some other code was omitted here

I executed it with fab replace_config:vim_sig=False,bash_sig=True, fab replace_config:False,True, and fab replace_config:0,1, but these commands copy vimrc to remote host and ignore the if vim_sig statement.

Why did this happen? How can I fix it?

My fabric version is 1.10.1, and the way I execute the fab with parameters was taken from here.

0

There are 0 best solutions below