zoukankan      html  css  js  c++  java
  • ansible 使用ping模块和时间同步模块

    命令格式

    ansible 主机清单中IP或分组名称 -m 模块

    ping模块应用

    ansible 192.168.1.6 -m ping 或者 ansible new-machine -m ping

    输出结果:

    [root@server ansible]# ansible new-machine -m ping
    [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
    192.168.1.6 | SUCCESS => {
    "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
    }
    [root@server ansible]#

    ansible 192.168.1.6 -m cron -a 'name="test cron1" job="nepdate time1.aliyun.com" monute=0 hour=*/1'

    [root@server ansible]# ansible 192.168.1.6 -m cron -a 'name="test cron1" job="ntpdate time1.aliyun.com" minute=0 hour=*/1'
    [WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
    192.168.1.6 | CHANGED => {
    "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": true,
    "envs": [],
    "jobs": [
    "test cron1"
    ]
    }

    目标机器查看crontab -l

    [root@client ~]# crontab -l
    #Ansible: test cron1
    0 */1 * * * ntpdate time1.aliyun.com
    [root@client ~]#

    注意事项:

    国内的话,选择阿里或腾讯云的时钟源

    time.pool.aliyun.com

    time1.cloud.tencent.com

    海外的话,选择微软或者google的时钟源

    time.windows.com

    time1.google.com

    参考链接:

    https://docs.ansible.com/ansible/latest/modules/cron_module.html#cron-module

  • 相关阅读:
    WPS JS宏
    WPS基础
    算法文章收藏
    辩论赛
    物流系统
    C#导出excel复杂表格(单元各合并)
    VUE复杂表格合并
    Linux系统创建一个npm命令行工具
    Java使用技巧记录
    Ubuntu系统安装nodejs及npm
  • 原文地址:https://www.cnblogs.com/ccielife/p/13488134.html
Copyright © 2011-2022 走看看