首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

SaltStack常用模块介绍

acl, aliases, alternatives, apache, archive, artifactory, blockdev, btrfs, buildout, cloud, cmd, composer, config, container_resource, cp, cron, data, defaults, devmap, dig, disk, django, dnsmasq, dnsutil, drbd, elasticsearch, environ, etcd, event, extfs, file, gem, genesis, git, grains, group, grub, hashutil, hg, hipchat, hosts, http, img, incron, ini, introspect, ip, iptables, jboss7, jboss7_cli, key, kmod, locale, locate, logrotate, lowpkg, match, mine, modjk, mount, network, openstack_config, pagerduty, pillar, pip, pkg, pkg_resource, postfix, publish, puppet, pyenv, raid, random, random_org, rbenv, ret, rsync, runit, rvm, s3, saltutil, schedule, scsi, sdb, seed, selinux, serverdensity_device, service, shadow, slack, smtp, sqlite3, ssh, state, status, supervisord, sys, sysctl, syslog_ng, system, test, timezone, user, vbox_guest, virtualenv, webutil, xfs

03

python 远程执行代码 fabr

fabric应用:                1、fab -H 172.23.177.40,172.23.177.41 host_type                2、fab host_type check_ver                3、role: 当client较多时可以定义角色,然后按角色进行操作。                     #!/usr/bin/pyhton                     from fabric.api import *                     env.user = 'root'                     env.password = 'vagrant'                     env.roledefs = {                          'web': ['172.23.177.41','172.23.177.43'],                          'dns': ['172.23.177.46','177.23.177.73']                     }                     def test():                         run('uname -a')                run:                     fab -R web test                result:                     [172.23.177.41] Executing task 'test'                     [172.23.177.41] run: uname -a                     [172.23.177.41] out: Linux salt-master 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux                     [172.23.177.41] out:                     [172.23.177.43] Executing task 'test'                     [172.23.177.43] run: uname -a                     [172.23.177.43] out: Linux salt-minion-3 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux                     [172.23.177.43] out:                     Done.                     Disconnecting from 172.23.177.43... done.                     Disconnecting from 172.23.177.41... done.                     #从结果可以看到,fab只执行了属于web组的client。                4、extend属性                     from fabric.api import env, run                     env.hosts.extend(['host3', 'host4'])                     def test():                         run('uname -r')                     When this fabfile is run as fab -H host1,host2 mytask, env.hosts will then contain ['host1', 'host2', 'host3', 'host4'] at the time that mytask is executed.                5、fabfile中没有定义client,可以在命令行中指定                     fab mytask:hosts='172.23.177.41;172.23.177.46'                6、使用task方式:                     from fabric.api import

01
领券