Fabric bulk operation of remote operations master exercises

Source: Internet
Author: User

Fabric is a command-line-based automated deployment framework for Python that uses Docker to open two of containers to learn fabric.

#!/usr/bin/env python#-*-coding=utf-8-*- fromFabric.apiImport*env.hosts=[    '[Email protected]:22',    '[Email protected]:32',]env.passwords={    '[Email protected]:22':'*****',    '[Email protected]:32':'***',} @taskdefTask1 (): Run (' PS') @taskdefTask2 (): Run (' Uname-a') @taskdefdotask (): Execute (TASK1) execute (TASK2)

Execution results

[Email Protected]:/home#Fab dotask[[Email protected]:22] Executing task'Dotask'[[Email protected]114.215.86.228:22] Executing task'Task1'[[Email protected]114.215.86.228:22] Run:ps[[email protected]114.215.86.228:22] Out:pid TTY time Cmd[[email protected]114.215.86.228:22] out:26424 PTS/2 00:00:00Ps[[email protected]114.215.86.228:22] Out:[[email protected]114.215.86.228:32] Executing task'Task1'[[Email protected]114.215.86.228:32] Run:ps[[email protected]114.215.86.228:32] Out:pid TTY time Cmd[[email protected]114.215.86.228:32] out:59 pts/0 00:00:00Ps[[email protected]114.215.86.228:32] Out:[[email protected]114.215.86.228:22] Executing task'Task2'[[Email protected]114.215.86.228:22] Run:uname-A[[email protected]114.215.86.228:22] Out:linux Iz2893wjzgyz 3.13.0-32-generic#57-ubuntu SMP Tue Jul 03:51:08 UTC x86_64 x86_64 x86_64 gnu/linux[[Email protected]:22] Out:[[email protected]114.215.86.228:32] Executing task'Task2'[[Email protected]114.215.86.228:32] Run:uname-A[[email protected]114.215.86.228:32] Out:linux c368a2768e6b 3.13.0-32-generic#57-ubuntu SMP Tue Jul 03:51:08 UTC x86_64 x86_64 x86_64 gnu/linux[[Email protected]:32] Out:[[email protected]114.215.86.228:32] Executing task'Dotask'[[Email protected]114.215.86.228:22] Executing task'Task1'[[Email protected]114.215.86.228:22] Run:ps[[email protected]114.215.86.228:22] Out:pid TTY time Cmd[[email protected]114.215.86.228:22] out:26447 PTS/2 00:00:00Ps[[email protected]114.215.86.228:22] Out:[[email protected]114.215.86.228:32] Executing task'Task1'[[Email protected]114.215.86.228:32] Run:ps[[email protected]114.215.86.228:32] Out:pid TTY time Cmd[[email protected]114.215.86.228:32] out:63 pts/0 00:00:00Ps[[email protected]114.215.86.228:32] Out:[[email protected]114.215.86.228:22] Executing task'Task2'[[Email protected]114.215.86.228:22] Run:uname-A[[email protected]114.215.86.228:22] Out:linux Iz2893wjzgyz 3.13.0-32-generic#57-ubuntu SMP Tue Jul 03:51:08 UTC x86_64 x86_64 x86_64 gnu/linux[[Email protected]:22] Out:[[email protected]114.215.86.228:32] Executing task'Task2'[[Email protected]114.215.86.228:32] Run:uname-A[[email protected]114.215.86.228:32] Out:linux c368a2768e6b 3.13.0-32-generic#57-ubuntu SMP Tue Jul 03:51:08 UTC x86_64 x86_64 x86_64 gnu/linux[[Email protected]:32] Out:done. Disconnecting from114.215.86.228... done . Disconnecting from114.215.86.228:32 ... done.

However, the password is plaintext and unsafe, so it is still recommended to manage the server with the addition of a key.

Fabric bulk operation of remote operations master exercises

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.