• 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

      

  • 相关阅读:
    React全家桶+AntD 共享单车后台管理系统开发
    eclipse中通过Properties Editor插件查看配置文件中Unicode内容
    修改eclipse的编码格式
    后端接收前端数据中文乱码解决方案
    MySQL基础
    wordpress个人常用标签调用
    4gl游标cursor
    尝试写一写4gl与4fd
    foreach循環體控制
    保护wordpress后台登录地址
  • 原文地址:https://www.cnblogs.com/derekchen/p/7880767.html
Copyright © 2020-2023  润新知