zoukankan      html  css  js  c++  java
  • CentOS7 3 模块介绍 ansible

    ansible模块较多,对应可以查看相关文档,此处列出一下日常工作中常用的模块

    【copy】模块

    ansible agent -m copy -a "src=/root/test.sh dest=/tmp"
    

    【file】

    调用-s 参数,需要客户端能够无密码使用sudo命令;

    ansible agent -m file -a "dest=/tmp/test.sh mode=755 owner=root group=root" -s
    

    【script】

    ansible agent -m script -a "/tmp/test.sh"
    

    shell】创建用户

    ansible agent -m shell -a "/tmp/test.sh" 
    

    【group】创建组

    ansible agent -m group -a "name=test1 state=present" -s
    

    【user】

    ansible agent -m user -a "name=xuel home=/home/xuel state=present" -s
    

    【yum】

    可以提供的status:absent,present,installed,removed,latest
    ansible agent -m yum -a "name=httpd state=latest" -s
    

    【server】

    可以提供的status:running,started,stopped,restarted,reloaded

    【cron】

    ansible agent -m cron -a 'name="my job" minute=*/1 hour=* day=* month=* weekday=* job="/usr/sbin/ntpdate time1.aliyun.com"'
    

    【get_url】

    ansible agent -m get_url -a "url=http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm dest=/tmp"
    

    【synchronize】需要安装rsync

    ansible agent -m synchronize -a "src=/root/test.file dest=/tmp"
    模块默认使用的为推送push,如果想使用pull功能需添加mode=pull
    ansible agent -m synchronize -a "mode=pull src=/tmp/test.file dest=/root/"
    

    【ini_file】

    ansible agent -m ini_file -a "dest=/tmp/test.ini section=Mongo option=Host value=127.0.0.1"
    

    该模块Python需要安装ConfigParser

    转载自:https://www.centos.bz/2018/01/自动化运维工具ansible使用教程/

  • 相关阅读:
    101. Symmetric Tree(js)
    100. Same Tree(js)
    99. Recover Binary Search Tree(js)
    98. Validate Binary Search Tree(js)
    97. Interleaving String(js)
    96. Unique Binary Search Trees(js)
    95. Unique Binary Search Trees II(js)
    94. Binary Tree Inorder Traversal(js)
    93. Restore IP Addresses(js)
    92. Reverse Linked List II(js)
  • 原文地址:https://www.cnblogs.com/xibuhaohao/p/12221078.html
Copyright © 2011-2022 走看看