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

  • 相关阅读:
    echarts雷达图点击事件 包含(2.x,3.85,4.02)测试
    字体图标制作
    通过php动态传数据到highcharts
    smartgit试用到期不用序列号怎么继续使用
    项目的ip地址更改,用git从远程提取代码出现错误,提示为 network error connection timed out
    OC学习4——OC新特性之块(Block)
    OC学习3——C语言特性之指针
    OC学习2——C语言特性之函数
    OC学习1——基本数据类型
    JVM 内存的那些事
  • 原文地址:https://www.cnblogs.com/winter1519/p/9353042.html
Copyright © 2011-2022 走看看