zoukankan      html  css  js  c++  java
  • ansible实践

    ansible常用module

    ansible-doc 
        -l    List available modules
        -s    Show playbook snippet for specified module(s)
    
    ansible:
        
        ansible <host-pattern> [-f forks] [-m module_name] [-a args]    
            args:
                key=value
    
                注意:command模块要执行命令无须为key=value格式,而是直接给出要执行的命令即可;
    
            常用模块:
                command
                    -a 'COMMAND'
                    #查看web组磁盘空间使用率
                    ansible web -m command -a 'df -h'    
                    
                user
                    -a 'name= state={present|absent} system= uid='
                    #创建系统账户test,uid为444
                    ansible test -m user -a 'name=test state=present system=yes uid=444'
                    ansible test -m user -a 'name=test state=absent'
    
                group
                    -a 'name= gid= state= system='
                    
    
                cron
                    -a 'name= minute= hour= day= month= weekday= job= user= state='
                    #每3分钟做一次时间同步
                    ansible test -m cron -a 'name="custom job" minute=*/3 job="/usr/sbin/ntpdate 172.16.254.23"'
                    ansible test -m cron -a 'name="custom job" state=absent'
    
                copy
                    -a 'dest= src= mode= owner= group='
                    ansible test -m copy -a 'src=/root/a.sh dest=/tmp/ owner=root group=root mode=0755'
    
                file
                    -a 'path= mode= owner= group= state={directory|link|present|absent} src='
                    ansible test -m file -a 'path=/tmp/a.sh state=absent'
    
                ping                
                    ansible web -m ping
    
                yum
                    -a 'name= state={present|latest|absent}'
                    ansible test -m yum -a 'name=httpd state=latest'
                    ansible test -m yum -a 'name=httpd state=absent'
    
                service
                    -a 'name= state={started|stopped|restarted} enabled='
                    ansible test -m service -a 'name=httpd state=started enabled=yes'
                    
                shell
                    -a 'COMMAND'
                    ansible test -m shell -a 'chkconfig --list httpd' 
    
                script
                    -a '/path/to/script'
                    ansible test -m script -a '/root/a.sh'
    
                setup            
                    ansible web -m setup
                
                synchronize
                    -a 'src= dest= mode={pull|push} rsync_opts="auv"'                            
                    ansible webg:webappg -m synchronize -a 'src=/app/webapps/app/  dest=/app/webapps/app/  mode=push  rsync_opts="-av"'
  • 相关阅读:
    ACM的算法分类 2015-04-16 14:25 22人阅读 评论(0) 收藏
    初学Larevel 2014-08-21 11:24 90人阅读 评论(0) 收藏
    初学PHP&MySQL 2014-05-31 12:40 92人阅读 评论(0) 收藏
    codeforces 570 E. Pig and Palindromes (dp)
    codeforces 570 D. Tree Requests (dfs序)
    poj 2157 Maze (bfs)
    cf 570 C. Replacement (暴力)
    cf 570B B. Simple Game(构造)
    cf 570 A. Elections
    hdu 1429胜利大逃亡(续) (bfs+状态压缩)
  • 原文地址:https://www.cnblogs.com/chbo/p/7160081.html
Copyright © 2011-2022 走看看