Fabric实例
1:查看本地与远程主机信息
#!/usr/bin/python
from fabric.api import * env.user="lile"
env.hosts=['10.0.0.145','10.0.0.147']
env.password="" #@runs_once
def local_task():
local('uname -r')
def remote_task():
with cd("/tmp"):
run("ls")
def remote_task():
run("cd /tmp" && ls)
#!/usr/bin/python
from fabric.api import * env.user="lile"
env.hosts=['10.0.0.145','10.0.0.147']
env.password='' @runs_once
def input_raw():
return prompt("please input directory name:",default="/home") def worktask(dirname):
run("ls " + dirname) @task
def go():
getdirname = input_raw()
worktask(getdirname)

#!/usr/bin/python
from fabric.api import *
from fabric.context_managers import *
from fabric.contrib.console import confirm env.user="root"
env.gateway="10.0.0.12"
env.hosts=['10.0.0.145','10.0.0.147']
env.passwords={
'root@10.0.0.12:22':'root123456',
'root@10.0.0.145:22':'',
'root@10.0.0.147:22':''
} lpath="/fabric/5/apache-tomcat-8.5.12.tar.gz"
rpath="/tmp/install" @task
def put_task():
run('mkdir -p /tmp/install')
with settings(warn_only=True):
result = put(lpath,rpath)
if result.failed and not confirm("put file failed,Continue[Y/N]?"):
abort("Aborting file put task!") @task
def tar():
with cd("/tmp/install"):
run("tar -zxvf apache-tomcat-8.5.12.tar.gz") @task
def go():
put_task()
tar()
Fabric实例的更多相关文章
- Fabric 1.0的多机部署
Fabric1.0已经正式发布一段时间了,官方给出的单机部署的脚本也很完备,基本上傻瓜式的一键部署,直接运行官方的network_setup.sh up即可.但是在实际生产环境,我们不可能把所有的节点 ...
- 在Ubuntu中部署并测试Fabric 1.0 Beta
[更新:1.0Beta已经是过去式了,现在出了1.0.0的正式版,请大家参照 http://www.cnblogs.com/studyzy/p/7437157.html 安装Fabric 1.0.0 ...
- 006/搭建fabric(二)
准备vmware虚拟机,并安装完ubuntu系统后.继续搭建fabric运行环境... 0.打开终端,切换root身份.目的:后续操作即可不用sudo... 右键->open Terminal- ...
- 最近学习工作流 推荐一个activiti 的教程文档
全文地址:http://www.mossle.com/docs/activiti/ Activiti 5.15 用户手册 Table of Contents 1. 简介 协议 下载 源码 必要的软件 ...
- Service Fabric下删除实例并注销应用
Service Fabric下删除实例并注销应用: 以应用名称:Application1为例 1.打开PowerShell 2.连接集群: Connect-ServiceFabricCluster - ...
- fabric使用实例(发布web包的一个例子)
#!/usr/bin/env python # -*- coding: utf-8 -* #添加中文注释的编码 #fabfile.py from fabric.api import * env.use ...
- MySQL: Fabric 搭建 HA
搭建好Fabric之后,就可以在它的基础上创建HA Group. Shard Group.HA+Shard Group等.这里来说明一下如何快速的搭建HA环境. Fabric 192.168.2.23 ...
- MySQL:Fabric 安装
MySQL Fabric安装 MySQL Fabric是Oracle提供的用于辅助进行ha\sharding的工具,它的基本架构: 从上面看出,借助于Fabric, 可以搭建 HA 集群.Sharin ...
- Fabric远程自动化使用说明
背景: 关于Fabric的介绍,可以看官网说明.简单来说主要功能就是一个基于Python的服务器批量管理库/工具,Fabric 使用 ssh(通过 paramiko 库)在多个服务器上批量执行任务.上 ...
随机推荐
- Apache Solr入门教程(初学者之旅)
Apache Solr入门教程(初学者之旅) 写在前面:本文涉及solr入门的各方面,建议边思考边实践,相信能帮助你对solr有个清晰全面的了解并能简单实用. 在Apache Solr初学者教程的这个 ...
- 雷林鹏分享:jQuery EasyUI 数据网格 - 使用虚拟滚动视图显示海量数据
jQuery EasyUI 数据网格 - 使用虚拟滚动视图显示海量数据 数据网格(datagrid)的虚拟滚动特性可以用来显示大数量的记录而不需要分页. 当滚动垂直滚动条时,数据网格(datagrid ...
- guxh的python笔记八:特殊方法
1,类的特殊方法 新建一个类,本章内容中的特殊方法如果不创建类或新增方法,默认使用的就是下面的类: class Foo: """this is Foo"&q ...
- android -------- 压缩图片文件工具类
项目中常常遇到文件压缩问题,上传文件大小限制 今天简单的分享一点干货,文件压缩,图片压缩,压缩Bitmap 主要通过尺寸压缩和质量压缩,以达到清晰度最优 效果图 源码地址: https://githu ...
- 解决无法连接mysql问题
解决无法连接mysql问题 在my.ini文件下加入explicit_defaults_for_timestamp 清空data文件夹 Cmd初始化mysql 输入>Mysqld --in ...
- CentOS7下mariadb日常管理
在CentOS7下,官方提供的mysql的rpm包就是mariadb,可查看mariadb包信息 [root@host ~]$rpm -qi mariadb # 需要先安装该包 Name : mari ...
- linux中执行shell命令的几种常用方法
1 切换到shell脚本所在目录执行shell脚本: cd /test/shell ./test.sh 2 以绝对路径的方式执行shell脚本: /test/shell/test.sh 3 直接使用b ...
- linux安装elasticsearch-head和elasticsearch-analysis-ik及遇到的各种问题
1.获取elasticsearch-head http://mobz.github.io/elasticsearch-head/ 下载并解压 wget https://github.com/mobz/ ...
- django1
* <pre>━━━━━━神兽出没━━━━━━ * ┏┓ ┏┓ * ┏┛┻━━━┛┻┓ * ┃ 王 ┃ * ┃ ┃ * ┃ ┳┛ ┗┳ ┃ * ┃ ┃ * ┃ ┻ ┃ * ┃ ┃ * ...
- Python中文问题
读取数据库中文是?? 解决如下 一.python2版本需要在 文件的开头要加上编码设置来说明文件的编码 python3版本以上不需要 #encoding=utf-8 二.在连接数据的连接参数里加上字 ...