Ansible
2.模块的使用
authorized_key模块添加sshkey认证
YUM模块的使用
COPY模块的使用
file
cron
firewalld
pam_limits
mysql_db
mysql_user
selinux
sysctl
yum
3.playbooks
初始化新安装CentOS7
模块文档工具ansible-doc
shell+register+when+模块RETURN变量
本文档使用 MrDoc 发布
-
+
首页
cron
# cron 定时任务模块,逻辑与crontab完全相同 ## 配置一个定时任务执行脚本 ```yaml - name: 配置定时任务 cron: name: "Monitor mongodb" # 定时任务的名称,一定要填写,方便删除。 env: "DB=test" # 配置环境变量,没有需要不用添加 user: root # 指定运行定时任务的用户 minute: "*/1" # 默认为"*",不修改可以不写,( 0-59, *, */2, etc ) hour: "*" # 默认为"*",不修改可以不写,( 0-23, *, */2, etc ) day: "*" # 默认为"*",不修改可以不写,( 1-31, *, */2, etc ) month: "*" # 默认为"*",不修改可以不写,( 1-12, *, */2, etc ) weekday: "*" # 默认为"*",不修改可以不写,( 0-6 for Sunday-Saturday, *, etc ) reboot: false # 默认为false,不修改可以不写,reboot后执行的任务 job: "/bin/bash /src/ddns/aliddns.sh > /tmp/mongo_monit.log 2>&1" state: present # 默认为present,如果要删除指定的任务可以修改为absent ``` ## 帮助文档 `ansible-doc cron` ```yaml EXAMPLES: - name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null" cron: name: "check dirs" minute: "0" hour: "5,2" job: "ls -alh > /dev/null" - name: 'Ensure an old job is no longer present. Removes any job that is prefixed by "#Ansible: an old job" from the crontab' cron: name: "an old job" state: absent - name: Creates an entry like "@reboot /some/job.sh" cron: name: "a job for reboot" special_time: reboot job: "/some/job.sh" - name: Creates an entry like "PATH=/opt/bin" on top of crontab cron: name: PATH env: yes job: /opt/bin - name: Creates an entry like "APP_HOME=/srv/app" and insert it after PATH declaration cron: name: APP_HOME env: yes job: /srv/app insertafter: PATH - name: Creates a cron file under /etc/cron.d cron: name: yum autoupdate weekday: "2" minute: "0" hour: "12" user: root job: "YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" cron_file: ansible_yum-autoupdate - name: Removes a cron file from under /etc/cron.d cron: name: "yum autoupdate" cron_file: ansible_yum-autoupdate state: absent - name: Removes "APP_HOME" environment variable from crontab cron: name: APP_HOME env: yes state: absent ```
zhangky
2021年12月22日 11:37
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码