Chinaunix首页 | 论坛 | 博客
  • 博客访问: 239266
  • 博文数量: 49
  • 博客积分: 246
  • 博客等级: 二等列兵
  • 技术积分: 1034
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-02 13:18
文章分类

全部博文(49)

分类: 系统运维

2015-07-07 09:14:47


点击(此处)折叠或打开

  1. # encoding: UTF-8


  2. from fabric.colors import *
  3. from fabric.api import *
  4. from fabric.context_managers import *
  5. from fabric.contrib.console import confirm
  6. import time


  7. env.user = 'root'

  8. env.roledefs = {
  9.     'webserver': ['172.20.10.10','172.20.10.11'],
  10.     'dbserver': ['172.20.10.250']
  11. }

  12. env.passwords = {
  13.     'root@172.20.10.10:22' : 'password',
  14.     'root@172.20.10.11:22' : 'password',
  15. }


  16. @roles('webserver')

  17. def webtask():
  18.     print yellow('Install nginx php php-fpm...')
  19.     with settings(warn_only=True):
  20.      run("yum install nginx -y")
  21.      run("yum install php-fpm php-mysql php-mbstring php-xml php-mcrypt php-gd -y")
  22.      run("chkconfig --levels 235 php-fpm on")
  23.      run("chkconfig --levels 235 nginx on")

  24. @roles('dbserver')

  25. def dbtask():
  26.     print yellow("Install mysql ....")
  27.     with settings(warn_only = True):
  28.         run("yum install mysql mysql-server mysql-client mysql-libs mysql-commadn -y")
  29.         run("chkconfig --levels 235 mysqld on")

  30. @roles ('webserver','dbserver')

  31. def publictask():
  32.     print yellow("Install epel ntp....")
  33.     with settings(warn_only = True):
  34.         run("rpm -Uvh style="color:#0000CC;">)
  35.         run("yum install ntp -y")

  36. def deploy():
  37.     execute(publictask)
  38.     execute(webtask)
  39.     execute(dbtask)

阅读(2735) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~