Fabric role Basic function combination function application

Source: Internet
Author: User
Code
#/usr/bin/env python
#coding =utf-8 from

fabric.api import *

# define machine list
m110= "Root@192.168.0.110:22"
m228= "root@192.168.0.228:22"

# define machine password
env.passwords = {
    m110: ' 123 ',
    m228: ' 123 '
}

# Define machine grouping
env.roledefs = {
   ' r110 ': [m110],
   ' Rall ': [m110,m228]
}

# define basic function
def getuptime () : {
    run (' Uptime ')
}

# defines the combination function
@roles (' Rall ')
def all_getuptime (): {
    getuptime ()
}
Meet the scene view uptime on all machines
Fab all_getuptime
View uptime only on 110
Fab-h 192.168.0.110 Getuptime

Or

Fab-h m110 Getuptime//This method will cause an error because m110 only allows calls inside the fabfile.py
Tactical Assumptions 3 machines each machine must meet basic conditions deploy some software on each machine separately

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.