zoukankan      html  css  js  c++  java
  • Ansible常用模块之系统类模块

    cron模块

    管理远程主机上的计划任务

    [root@tiandong ansible]# ansible all -m cron -a "name='cron test' minute=5 hour=1 job='echo test'"

    每天15分执行

    [root@tiandong ansible]# ansible all -m cron -a "name='cron day test' minute=5 hour=1 day=*/3 job='echo test'"

    [root@tiandong ansible]# ansible all -m cron -a "name='test special time' special_time=reboot job='echo test'"

    定义计划任务,在重启时执行

    [root@tiandong ~]# ansible all -m cron -a "name='test special time' special_time=hourly job='echo test' backup=yes"

    存在相同的name,则会修改之前的计划任务,但是加了backup之后会先进行备份然后在创建计划任务

    [root@tiandong ~]# ansible all -m cron -a "name='test special time' state=absent backup=yes"

    删除计划任务。有backup参数就是先进行备份,backup_file备份的位置

    [root@tiandong ~]# ansible all -m cron -a "user=tom name='the special time' special_time=hourly job='echo test'"

    默认的计划任务是root用户,但是可以指定用户。

    在远程主机上查看

     

    [root@tiandong ~]# ansible all -m cron -a "user=tom name='the special time' special_time=hourly job='echo test' disabled=yes backup=yes"

    当要注释某个计划任务的时候,加disabled参数。

    Service模块

    管理远程主机上的服务

    [root@tiandong ~]# ansible all -m service -a "name=httpd state=started"

    启动远程主机上的httpd服务

    [root@tiandong ~]# ansible all -m service -a "name=httpd state=stopped"

    关闭远程主机上的httpd服务

    [root@tiandong ~]# ansible all -m service -a "name=httpd enabled=yes"

    远程主机上的httpd服务设置为开机自启动

    User模块

    管理远程主机上的用户,(创建用户,修改用户,删除用户为用户创建密钥对等)

    [root@tiandong ~]# ansible all -m user -a "name=thunder"

    创建用户thunder

    [root@tiandong ~]# ansible all -m user -a "name=thunder state=absent"

    删除用户thunder,但是不会删除家目录

    [root@tiandong ~]# ansible all -m user -a "name=thunder state=absent remove=yes"

    删除用户thunder,同时删除thunder的家目录信息

    [root@tiandong ~]# ansible all -m user -a "name=thunder comment='www.thunder.com'"

    注定用户的注释信息

     

    [root@tiandong ~]# ansible all -m user -a "name=winter group=thunder uid=600 shell=/sbin/nologin"

    添加一个用户,设置组,uid,以及shell

  • 相关阅读:
    深入学习webpack(四)
    深入学习webpack(三)
    深入学习webpack(二)
    深入学习webpack(一)
    (转载)路径中 斜杠/和反斜杠 的区别
    jquery中beforeSend和complete的使用 --- 提高用户体验&&设置请求头
    好的用户界面-界面设计的一些技巧
    使用vue Devtools
    vue脚手架 && 实例
    表单(中)-EasyUI Combogrid 组合网格、EasyUI Numberbox 数字框、EasyUI Datebox 日期框、EasyUI Datetimebox 日期时间框、EasyUI Calendar 日历
  • 原文地址:https://www.cnblogs.com/winter1519/p/9353042.html
Copyright © 2011-2022 走看看