zoukankan      html  css  js  c++  java
  • Ansible-Hoc--样例

    一。常用场景

    1. 列出支持的模块及模块功能说明:

        

    2. sudo用法:

        

    3. 检查服务器存活,复制本地文件到远程:

        

    4. 多线程判断服务器的存活:

         

    5.  显示所有主机的hostname:

         

    6. 列出主机组的主机列表

        

    7. 复杂点的场景

       

    8. 查看主机组的磁盘容量:command模块

        ansible testserver -a "df -lh"

    9. 查看主机组的内存 :shell模块

        ansible testserver -m shell -a "free -m"

    10. 安装redhat-lsb

         ansible testserver -m yum -a 'name=epel-release state=present'

    11. 查看系统版本号

        ansible testserver -m command -a 'epel-release -a'

    12.安装ntp服务

        ansible testserver -m yum -a 'name=ntp state=present'

    13.启动ntp,并设置为开机启动

        ansible testserver -m service -a 'name=ntpd state=started enabled=yes'

    二。用户管理:

      1.  新增组:

          ansible testserver -m group -a 'name=jar state=present'

      2.  新增用户:

          ansible  testserver -m user -a 'name=jar shell=/bin/bash groups=jar append=yes home=/home/jar/ state=present'

      3. 修改密码:涉及密码加密的问题

          ansible -m user -a 'name=jar shell=/bin/bash password=xxxxxx update_password=always'

      4. 修改用户组:

          ansible -m user -a 'name=jar groups=jar append=no'

      5.  修改用户属性:

          ansible -m user -a 'name=jar expires=99999'

     6.  删除用户:

          ansible -m user -a 'name=jar state=absent remove=yes

      

  • 相关阅读:
    卷积神经网络(3)
    卷积神经网络(2)
    五款最佳Linux下载管理器推荐
    SSH如何通过公钥连接云服务器
    揭露QPS增高后的秘密
    总结六条对我们学习Linux系统有用的忠告
    第一款支持容器和云部署的开源数据库Neo4j 3.0
    /etc/bashrc和/etc/profile傻傻分不清楚?
    手把手教你crontab排障
    awk系列:在awk中如何使用流程控制语句
  • 原文地址:https://www.cnblogs.com/derekchen/p/7880767.html
Copyright © 2011-2022 走看看