zoukankan      html  css  js  c++  java
  • ansible安装和批量执行命令

    yum install -y ansible

       

       

    编辑 /etc/ansible/hosts 文件

       

    # This is the default ansible 'hosts' file.
    #
    # It should live in /etc/ansible/hosts
    #
    # - Comments begin with the '#' character #
    #来表示注释
    # - Blank lines are ignored #
    空白行被忽略
    # - Groups of hosts are delimited by [header] elements #
    主机组 需要在【】下面
    # - You can enter hostnames or ip addresses #
    可以写主机名或者ip地址
    # - A hostname/ip can be a member of multiple groups #
    一台主机可以在多个组里面

       

    [web] #客户端组

    192.168.181.133 #客户局IP地址

    192.168.181.134

       

    批量执行web组中的命令

    ansible web -m shell -a "ifconfig eth0 | awk -F '[:. ]+' 'NR==2{print $6}'"

       

    双引号内的命令体,shell也可以换成command 两者的区别是command不支持例如管道符之类的特殊符号。

       

    传送本地文件到客户机上

    ansible group1 -m copy -a "src=/root/xmr.sh dest=/root/"

       

    运行客户机上的脚本文件

       

    ansible group1 -m shell -a "sh /root/xmr.sh"

  • 相关阅读:
    基因id转换
    Trinity的分步运行
    免费的稳定的SVN托管的服务器
    游戏化
    一个华裔男孩在美国的成长之路
    你懂USB和Type-C吗
    ios调试小技巧
    swift开发笔记19
    iOS 3DTouch应用
    iCloud实现APP多设备数据同步
  • 原文地址:https://www.cnblogs.com/withfeel/p/14267119.html
Copyright © 2011-2022 走看看