Ansible Playboos implement upload files, create crontab

Source: Internet
Author: User

Demand:
Upload 3 shell scripts to the specified directory, set permissions to 755, owner, group Root
and set under Crontab

* * * * * /path/file

When it comes to machines, use Ansible to perform in batches.
involves copy, cron module

Copy Example:

Examples- name: example copying file with owner and permissions  copy:    src: /srv/myfiles/foo.conf    dest: /etc/foo.conf    owner: foo    group: foo    mode: 0644

Cron Example:

Examples# 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"

The final scenario is as follows:

---- hosts: ctijk  remote_user: toptea  become: yes  become_method: sutasks:- name: transfer file to server  copy:     src: /tmp/iomonitor.sh    dest: /opt/iomonitor.sh    owner: root    group: root    mode: 0755- name: transfer file to server  copy:     src: /tmp/topmonitor.sh    dest: /opt/topmonitor.sh    owner: root    group: root    mode: 0755- name: transfer file to server  copy:     src: /tmp/cpumonitor.sh    dest: /opt/cpumonitor.sh    owner: root    group: root    mode: 0755- cron:    name: "cti cpumonitor"    minute: ‘*‘    job:  "/opt/cpumonitor.sh"- cron:    name: "cti iomonitor"    minute: ‘*‘    job:  "/opt/iomonitor.sh"- cron:    name: "cti topmonitor"    minute: ‘*‘    job:  "/opt/topmonitor.sh"

Ansible Playboos implement upload files, create crontab

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.